Aiden Markram cracked a crucial half-century as table-topping South Africa broke their 24-year World Cup jinx against Pakistan with a nervy one-wicket victory and inched closer to securing a semi-final place with their fifth win in six matches.
South Africa began well chasing 271 as Quinton de Kock (24) and Temba Bavuma (28) landed early blows before Pakistan struck back with timely wickets, but Markram (91) held his nerve to take them close and they eventually got home in 47.2 overs.
Usama Mir (2-45) came on as a concussion substitute after Shadab Khan hurt himself fielding and he got rid of Rassie van der Dussen and took a catch to dismiss Heinrich Klaasen while David Miller (29) and Marco Jansen (20) departed after cameos.
But the Proteas would not be denied a first victory batting second in the event despite Markram falling to Usama and Gerald Coetzee to Shaheen Afridi (3-45), as Keshav Maharaj and Tabraiz Shamsi hung on to settle the tense contest.