South Africa were 41 for one wicket in reply at tea, trailing by just 58 on a dry and dusty pitch that is tailor-made for spin bowling.
Graeme Smith (12 not out) and Dean Elgar (one not out), in the side at number three for expectant father Hashim Amla, will look to build a lead in the final session of the day after South Africa lost opener Alviro Petersen (26) shortly before tea.
Pakistan-born Tahir, playing for the first time since conceding 260 runs without a wicket against Australia in Adelaide last November, made the most of the spin-friendly conditions as he recorded figures of 5-32 after he replaced Robin Peterson as South Africa's main spin option.
He was ably supported by paceman Dale Steyn, who took 3-38 as South Africa brutally exposed the fragility of Pakistan's top order, who were hoping to make the most of the conditions after winning the toss and electing to bat first.
Four of Tahir's victims were bowled as he made expert use of the googly turning back into the right-handed batsmen, as well as his 'slider' quicker ball that does not turn but beats the batsmen for pace.
He bowled Shan Masood for 21, before trapping Pakistan skipper Misbah-ul-Haq (two) leg before wicket. Adnan Akmal (0), Asad Shafiq (10) and Mohammad Irfan (0) were all bowled.
Steyn collected the first wicket with just the second ball of the morning as centurion from the first test Khurram Manzoor guided the ball to gully without scoring.
He also claimed the big wicket of Younus Khan (10), and bowled number 11 Junaid Khan to wrap up the innings.
Morne Morkel was the other South African bowler to prosper as he trapped Azhar Ali in front for 19.
South Africa trail 1-0 in the two-match series, having not lost an away series since 2006.