Tahir (three for 98) and Duminy (three for 67) were the central figures for the world's top test team, whose much-vaunted pace attack was made to look impotent on a wicket offering very little in the way of pace and bounce.
Asad Shafiq, who hit a career-best 130 to stall the South African victory charge, was the final wicket to fall when he was stumped by AB de Villiers off the bowling of Duminy.
He had put on 197 for the fifth wicket with skipper Misbah-ul-Haq (88) that frustrated the Proteas until an hour after lunch.
Pakistan were eventually bowled out for 326 in their second innings, a vast improvement on the woeful 99 they managed on day one, but still left them 92 runs shy of South Africa's mammoth 517.
Pakistan won the first Test by seven wickets.
The teams will now play a five-match one-day international series starting on Wednesday, followed by two Twenty20 games.
- Sports & Recreation
- AB de Villiers