South Africa built a lead of 323 runs over Pakistan on day four of the second and final Test in Abu Dhabi as they closed on 173 for four in their second innings.

That came after Pakistan avoided the follow-on by being dismissed for 434, a maiden Test half-century from Abdur Rehman helping them do so.

He hit 60 in 139 balls, including a six to reduce the deficit to under 200 as Pakistan rallied following the dismissal of Misbah-ul-Haq (77) to the first ball of the day when he was trapped in front by Dale Steyn.

Umar Gul then made 21, Tanvir Ahmed 30 and Mohammad Sami an unbeaten two to offer Rehman, who also hit eight fours, good support.

Steyn finished with figures of four for 98 when Pakistan were eventually bowled out while Paul Harris took three for 98.

South Africa, minus Graeme Smith with an injured finger, opened with Hashim Amla and Alviro Petersen and the pair put on 81 for the first wicket in good time.

Amla made 62 in 64 balls and Petersen 35 in 49 balls before Petersen was caught by Younus Khan off Rehman, who then produced a sharp turning delivery to bowl Amla.

AB de Villiers was then trapped in front by Rehman for 25 and Jacques Kallis caught by Taufeeq Umar off Mohammad Hafeez for ten before Ashwell Prince (27 not out) and Mark Boucher (13 not out) guided South Africa to the close.