(CNN) -- Pakistan were indebted to an inspired bowling performance from their captain to survive a major scare from minnows Canada and maintain their 100 per cent record at the Cricket World Cup.
Shahid Afridi took five wickets in a devastating spell as Canada were bowled out for 138 chasing a modest Pakistan total of 184.
At 104-4 Canada looked to be on target to match Ireland's stunning win over England on Wednesday before Afridi decimated their middle and lower order, adding a superb run out to his five wickets.
Canada lost their final six wickets for just 36 runs as Pakistan surged to the top of Group A with three wins from three matches.
But it could have been a very different story had Afridi not rescued his side after they toiled against Canada's bowling attack..
Pakistan lost wickets at regular intervals in their innings with their top three batsman failing to make more than 16.
Misbah-ul-Haq and Umar Akmal put together a partnership of 73 before the latter fell for 48 to the bowling of Balaji Rao.
Afridi added 20 off 17 balls before he was dismissed by Rizwan Cheema.
Harvir Baidwan was the pick of Canada's bowlers, recording figures of 3-35. Balaji Rao, Rizwan Cheema and Jimmy Hansra took two wickets each.
Canada were reduced to 16-2 in their reply but recovered to 104-4 with Hansra well set. But Afridi changed the game with a ruthless display of spin bowling.
He accounted for Ashish Bagai, Hansra, Cheema, Tyson Gordon and Baidwan before removing Balaji Rao with a direct hit as the batsmen attempted a single. Wahab Riaz polished off the match by bowling Henry Osinde.
Earlier, South Africa thrashed the Netherlands by 231 runs as they recorded their second victory in the competition to top Group B.
Hashim Amla and AB De Villiers both hit centuries as South Africa raced to an impressive 351-5 off their 50 overs.
In reply the Netherlands were bowled out for just 120 as spinner Imran Tahir took three wickets. Robin Peterson and Jacques Kallis took two apiece.