South Africa kept their seven-year unbeaten away record intact with an innings and 92-run win over Pakistan in the second and final Test in Dubai on Saturday, squaring the two-match series 1-1.
It was a thorough and professional comeback by the world number one Test team after going down in last week's first Test by seven wickets, but the Proteas out-batted and out-bowled Pakistan at Dubai stadium.
The win was completed with a day and 9.5 overs to spare when Pakistan were bowled out for 326 in their second innings after they conceded a big 418-run lead in the first innings.
But Pakistan did not go down without a fight as Asad Shafiq (130) notched his fourth Test hundred and, along with skipper Misbah-ul Haq (88), frustrated the South Africans during a 197-run stand for the fifth wicket.
Leg-spinner Imran Tahir finished with 3-98 and took a total of eight wickets in the match, while part-time right-arm offbreak bowler Jean-Paul Duminy took Shafiq's wicket on the way to career best figures of 3-67.
South African skipper Graeme Smith praised his team.
"It was an outstanding four days for us, to respond in these conditions where I don't think Pakistan have lost before. We got most things right in this game. Anytime you bowl a team out for 99 you've gone way ahead in the Test match," said Smith.
Smith's counterpart Misbah rued their first innings failure.
"I am disappointed not to have won the series in these conditions," said Misbah. "We couldn't recover after being bowled out for 99. Smith and AB de Villiers batted really well."
However, South Africa's deserved win was tainted by a ball-tampering row on Friday, when Faf Du Plessis was caught on television cameras scratching the ball on the zip of his trousers.
The on-field umpires Rod Tucker of Australia and Ian Gould of England along with television umpire Paul Reiffel warned Smith, changed the ball and gave five penalty runs to Pakistan.
The ICC (International Cricket Council) match referee David Boon of Australia then fined Du Plessis 50 percent of his match fee on Saturday.
Pakistan were left to rue their low score of 99 in the first innings which never allowed them to add to their only series win over South Africa in 2003 and, after their rivals piled up a mammoth 517 runs in reply, the writing was on the wall.
But when it looked like Misbah and Shafiq would guide Pakistan towards safety, the Pakistani skipper fell to a smart move by his counterpart Smith, who brought on part-timer Dean Elgar, and the left-hand slow bowler did not take long to make an impact.
Misbah's miscued drive off Elgar was well caught by Jacques Kallis, ending a 349-minute vigil in which he hit six boundaries and a six off 218 balls.
Shafiq reached his hundred with a superb on-drive off Duminy for his 11th boundary to complete his second hundred against South Africa.
In the morning, Misbah and Shafiq had added injury to South Africa's insult by batting with a resolve to fight hard after they resumed at 132-4.
Shafiq, on 36, got a reprieve early in the day when a leg-before decision by Australian umpire Rod Tucker was overturned on review. The unlucky bowler was paceman Vernon Philander in the fifth over in the day.
Shafiq, who scored 54 in Pakistan's seven-wicket win in last week's first Test in Abu Dhabi, reached his ninth Test fifty when he guided Duminy towards third man.
In all Shafiq batted for seven hours, hit 15 boundaries and a six in a 320-ball knock, improving on his highest score of 111 made against the same opposition in Cape Town earlier this year.
Misbah followed Shafiq, reaching his 22nd half-century at Test level with a single towards third man off paceman Morne Morkel.
The highlight of the match was Smith's epic 234 and AB de Villiers' 164 during their all-time South African Test record stand for the fifth wicket of 338.
The two teams now play a five-match one-day series, the first of which will be in Sharjah on Wednesday. They will also play two Twenty20 internationals.