Tahir finished with 5-32 and was ably supported by fit-again paceman Dale Steyn (3-38) as Pakistan were skittled out for 99 in 36.4 overs at Dubai stadium,after they had won the toss and elected to bat.
By tea South Africa, seeking a win to level the two-match series, had reached 41 for one, with Graeme Smith on 12 and Dean Elgar on two. Opener Alviro Petersen fell lbw to left-arm spinner Zulfiqar Babar for 26.
Tahir, playing his first Test since November 2011, dismissed opener Shan Masood (21), Misbah-ul Haq (two) and Akmal (nought) off just 11 deliveries to leave Pakistan in tatters at 60-6 by lunch.
Steyn, cleared to play despite a hamstring injury, had dismissed opener Khurram Manzoor off the second delivery of the match and then dismissed Younis Khan for 10 on a pitch which looked good for batting.
More From This Section
Steyn, doubtful to play after sustaining the injury on Sunday, showed no sign of discomfort as he dismissed Manzoor with a sharp outswinger, which was caught in the gully by Faf du Plessis.
Azhar Ali then put on 38 for the second wicket with Masood before he was trapped lbw by paceman Morne Morkel for 19.