Port Elizabeth - Ahmed Shehzad's century and some late hitting by Pakistan have set South Africa a victory target of 263 in 45 overs to stay alive in the three-game one-day international series on Wednesday.
Boosted by Shehzad's 102, the opener's third ODI hundred, Pakistan finished on 262 in the rain-shortened match at St. George's Park, giving the tourists a strong chance of a first ODI series victory anywhere over the Proteas.
Pakistan won its first ODI at Cape Town's Newlands on Sunday for a 1-0 series lead.
Shehzad survived Dale Steyn's (6-39) early onslaught, when South Africa's fast bowler knocked out Nasir Jamshed's off stump in the first over and had Mohammad Hafeez caught behind for 8 on the way to his career-best figures.
Shehzad ran himself out needlessly in the 35th after being sent back by Umar Akmal, but Akmal finished strongly with 42 off 30 balls for a challenging total on a Port Elizabeth pitch that isn't ever easy to score on, especially batting second.
Newcomer Bilawal Bhatti also took on Steyn at the end, hitting the world's top pace bowler for three fours in an over in his 21 off 14 balls before edging behind to wicketkeeper Quinton de Kock swinging for a fourth boundary.
Steyn roared back for his six wickets after Shehzad's resistance and removed Shahid Afridi, Bhatti, Akmal and finally Saeed Ajmal off the last ball for his first six-wicket haul in 50-over internationals. The fast bowler also appealed successfully to have Anwar Ali out obstructing the field after a throw hit the Pakistan batsman on the shoulder as he raced to make his ground.
Steyn's fierce, aggressive finish underlined the pressure on South Africa, which drubbed Pakistan 4-1 in their recent ODI contest in United Arab Emirates, but now faces a first ever series loss to the same team.
Pakistan came through a difficult opening spell after being put in to bat in overcast conditions and after a two-hour rain delay on the south coast.
Shehzad played through that tricky start and emerged to hit eight fours and two sixes in his century to move Pakistan to an ideal position at 180 with 10 overs to go and six wickets in hand.
His run out when he set off for a quick single and had to turn around threatened to spoil Pakistan's momentum, but Akmal kept the runs coming with four fours and two sixes from No. 6 and kept Pakistan in position for a milestone victory.