Pakistan lost their last six wickets for 20 runs as South Africa won the fifth and final one-day international by 14 runs on Monday to win the series 3-2.
Pakistan were bowled out for 219 in 46.3 overs at the Gaddafi stadium, with Albie Morkel taking 4-44 and Makhaya Ntini 4-61.
Younis Khan (58) and Mohammad Yousuf (53) had shared a third wicket partnership of 106 in 134 balls to provide a solid platform but Pakistan lost their last six wickets in 36 balls.
South Africa clawed their way back after Younis was caught at deep midwicket by Morkel off Shaun Pollock in the 30th over.
Three overs later part-time spinner Jean-Paul Duminy had Yousuf slashing at a wide ball to be caught behind.
Captain Shoaib Malik then went for 23 before Misbah-ul-Haq (19), Shahid Afridi (9) and Sohail Tanvir, Rao Iftikhar and Shoaib Akhtar, who all failed to score, were undone by the swinging ball and some brilliant catching in the outfield.
"We played 90 percent better cricket. The total was chase able. We have learnt today what we need to do how to finish a game," Malik said.
Earlier, Pakistani strike bowler Shoaib made a dramatic return to international cricket by grabbing four wickets.
The controversial paceman, back in the side after a 13-match ban for his first one-dayer since September 2006, bowled with fire to trouble South Africa's batsmen on a slow pitch, taking four for 43.
Paceman Rao Iftikhar supported him well to claim 3-45, his third three-wicket haul in the series.
Jacques Kallis top-scored with 86 to anchor the innings after the visitors chose to bat first with opener Herschelle Gibbs hitting 10 fours in his 54.