Smith was 227 not out and a cramping AB de Villiers scored an unbeaten 157 as the pair set a new South African fifth wicket partnership record of 326 to put the top-ranked team firmly in command.
Smith, recently recovered from ankle surgery and looking considerably leaner after a tough pre-tour fitness regime, batted for more than 10 hours, passed 9000 test runs and notched his fifth double century in a dominant innings.
It is also the highest test score this year.
He offered Pakistan only one chance late in the day when he looked to have been caught off Azhar Ali but even after a review it proved inconclusive and Smith batted on.
De Villiers was dropped first ball by wicketkeeper Adnan Akmal off Mohammad Irfan and went on to punish the Pakistan attack as he notched his 17th test century despite suffering from cramps in the oppressive heat.
But he lived a much more charmed life, surviving a close run out call and another review when he looked trapped leg before by Saeed Ajmal straight after tea.
Just a single wicket fell on the second day as South Africa scored 332 runs in the three sessions, moving on considerably from their overnight tally of 128 for three.
Nightwatchman Dale Steyn was the only wicket to fall on Thursday, bowled by Irfan without offering a shot for seven in the first session before lunch.
South Africa now have the option of continuing to bat on the third day on Friday or declare early and put Pakistan in to bat for their second innings, after dismissing them for 99 in the first innings.
Pakistan lead the two-match series 1-0 after winning the first test in Abu Dhabi last week. The tests are being played in the Gulf due to security concerns in Pakistan.