The off-spinner (four for 74) was superbly supported by left-arm paceman Junaid Khan (three for 57) and fellow spinner Zulfiqar Babar (two for 51) as South Africa collapsed to 232 in their second innings on the fourth day at Sheikh Zayed Stadium.
That left Pakistan to score 40 runs for their overall fourth win over South Africa and take a 1-0 lead in the two-match series.
Pakistan made heavy weather of the small target losing openers Shan Masood (0), Azhar Ali (3) and Khurram Manzoor (4) in the space of seven runs by the fourth over.
Vernon Philander took two for 11 while Dale Steyn had one for seven.
Senior batsmen Younis Khan (9 not out) and Misbah-ul Haq (28 not out) were left to see off the target with the Pakistan captain deservedly hitting the winning six.
“It’s really unbelievable and a much-needed win for us,” said Misbah, whose team lost to minnows Zimbabwe in their last Test in September.
“It was a team effort and everyone contributed, especially the youngsters. Both openers and Zulfiqar Babar, they really did a tremendous job for us. I think everyone chipped in, especially with the bowling.”
South African captain Graeme Smith was left “extremely disappointed”.
“We have set really high standards for ourselves, but credit goes to Misbah and his boys, right from session one, they have been ahead in the game and played better cricket. Even though we showed good character in parts, our skills were not up to the mark,” said Smith.
It was AB de Villiers who hit a fighting 90 to help South Africa avoid an innings defeat while Robin Peterson scored a valiant 47 not out but it only delayed Pakistan’s win.
This is Pakistan’s fourth win over South Africa in 22 Tests and also broke South Africa’s unbeaten 15-Test run since losing to Sri Lanka at Durban in December 2011.
De Villiers added an invaluable 57 for the eighth wicket with Petersen to carry the match into the final session.
Peterson added an invaluable 42 for the ninth wicket with Vernon Philander (10), much to the frustration of the Pakistani bowlers.
De Villiers hit seven boundaries and a six off 157-ball in a resistance filled innings before he miscued a drive off paceman Junaid Khan with just three to avoid an innings defeat.
Pakistan’s bowlers had grabbed two wickets in the morning session to boost their chances on a pitch offering good turn after South Africa resumed at 72 for four, trailing by a big 121 runs.
Left-arm spinner Babar dismissed nightwatchman Steyn (7) and then paceman Jinaid Khan removed Jean-Paul Duminy (0) as South Africa struggled against a spirited bowling attack.
Steyn had frustrated Pakistan in the first hour, playing defensively till the 12th over of the day when Babar was introduced into the attack and with his first delivery bowled the nightwatchman.
Duminy, who hit 57 in South Africa’s first innings of 249, survived just five deliveries before he was trapped leg-before by Khan, leaving South Africa tottering at 109 for six.
Pakistan removed Faf du Plessis soon after lunch when Ajmal had him caught and bowled for eight.
De Villiers brought up his 33rd Test half-century with a big six off Babar. In all he hit seven boundaries and a six off 157 balls.
He hit a straight drive into the hands of cover off Khan, with just three needed to avoid an innings defeat.
Peterson and Philander further delayed the inevitable but Ajmal removed Philander and Morne Morkel in the same over to wrap up the innings.
The second and final Test will be played in Dubai from October 23.
South Africa 249 (Hashim Amla 118, JP Duminy 57; Mohammad Irfan 3 for 44) and 232 (AB de Villiers 90, Robin Peterson 47*; Saeed Ajmal 4 for 74, Junaid Khan 3 for 57) lost to Pakistan 442 (Khurram Manzoor 146, Shan Masood 75, Misbah-ul-Haq 100, Asad Shafiq 54; Vernon Philander 3 for 84, Dale Steyn 3 for 88) and 45 for 3 (Misbah-ul-Haq 28*; Vernon Philander 2 for 11) by 7 wickets.