Batting first, the 1992 champions posted 308 for seven with Haris Sohail's 59-ball 89 being the highlight of their innings. In reply, South Africa were stopped at 259 for nine in 50 overs.
With just three points from seven outings, South Africa are out of the tournament while Pakistan could still sneak into the semifinals, provided they win their remaining matches and other results go in their favour.
Shadab (3/50 in 10 overs) and Wahab Riaz (3/46 in 10) were Pakistan's most successful bowlers, while Amir picked up two wickets.
Skipper Faf du Plessis (63 off 79 balls) joined Quinton de Kock (47 off 60) early and the duo shared 87 runs for the second wicket to keep South Africa in the game.
Playing in his first match of the tournament since the outing against West Indies in their opener, Sohail smashed nine fours and three sixes in his 89-run knock.