Chasing Pakistan\'s challenging 262 in rain-shortened 45-over game, the hosts needed nine runs in the last over but fell short in a last-ball finish.
Port Elizabeth: Pakistan held on for a thrilling one-run win in the second one-day international on Wednesday to beat South Africa in an ODI series for the first time, making their short-notice tour an historic one.
Pakistan defended their 262 in a rain-shortened 45-over game by the smallest of margins as South Africa fell just short of the nine runs they needed off the last over at St. George's Park to take the three-game series to a decider.
Pakistan have the chance to be the first team ever to whitewash South Africa at home in an ODI contest in the final game.
A century partnership between Hashim Amla (98) and AB de Villiers (74) took South Africa to the brink of victory, but Amla's wicket fell off the last ball of the penultimate over. Junaid Khan took 3 for 42 for the victorious tourists, who just held on under intense pressure.
Earlier, Ahmed Shehzad's 102 set up victory for Pakistan, while Dale Steyn's career-best 6 for 39 was part of a losing effort for South Africa as the world's leading team in Test cricket continued to struggle for consistency in ODIs.
Following a 4-1 drubbing by the South Africans in United Arab Emirates at the start of the month, Pakistan turned the tables dramatically weeks later to send South Africa to their first one-day series defeat at home in over two years. The Pakistanis have the chance to become the first team to ever whitewash South Africa at home in the final game in Centurion this weekend.
Pakistan wasn't even meant to tour now, but was asked to fill a gap in South Africa's home schedule after India shortened their upcoming series. They also lost key players to injury before the series started and still came through for a momentous win.
Shehzad's 102 off 112 balls with eight fours and two sixes laid a winning platform in Port Elizabeth. He shared a 124-run partnership for the third wicket with Sohaib Maqsood (42) after coming through an early onslaught by Steyn in overcast conditions at the start of the day.
Umar Akmal added a quick-fire 42, but it was Pakistan's cool under pressure at the end that sealed their triumph as a partnership of 110 between Amla and De Villiers looked to have put South Africa on track to come from behind to win and stay alive in the series.
Saeed Ajmal struck for the crucial wicket of Amla on the last ball of the penultimate over and Khan had JP Duminy caught off the second ball of the last over as Pakistan fought until the end to make sure of their moment in history.