South Africa 271 for 9 (Markram 91, Afridi 3-45) beat Pakistan 270 (Shakeel 52, Babar 50, Shamsi 4-60, Jansen 3-43) by 1 wicket
Chennai: South Africa clung on to beat Pakistan by one wicket in the best game of the World Cup so far.
Chasing 271 in Chennai, the Proteas were in charge while Aiden Markram was at the crease, only for Markram to fall for 91 in a slide from 235-5 to 250-8.
Time was not an issue, but the South African tail was tasked with finding 21 runs against a pumped-up Pakistan attack.
Keshav Maharaj and Lungi Ngidi edged South Africa closer, before Ngidi was athletically held by Haris Rauf in his follow-through with 11 still needed.
Amid incredible tension, Pakistan reviewed an lbw shout against number 11 Tabraiz Shamsi from the final ball of Haris' spell. The not-out decision was upheld by the narrowest of margins, despite the ball being shown to be hitting leg stump (umpire's call).
With the pacemen bowled out, Pakistan had to return to spin and Maharaj pulled Mohammad Nawaz for the winning boundary with 22 balls to spare.
South Africa, who go top of the table, had earlier bowled out Pakistan for 270 thanks mainly to an enchanting spell of 4-60 by left-arm wrist-spinner Shamsi.
The Proteas' only defeat in six games was a shock loss to the Netherlands. They join India on 10 points, but go above the hosts on net run-rate, albeit having played a game more.
Victory against New Zealand in Pune on Wednesday will probably be enough to secure a spot in the last four.
For Pakistan, a fourth defeat in six games makes it incredibly difficult to reach the semi-finals.
Even if they win their final three matches, they will need some unlikely results to go their way.