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 regimen, 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.
Night-watchman 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.
Image: South African captain Graeme Smith celebrates a double century during the second day of the second Test against Pakistan at the Dubai International Cricket Stadium
Photograph: MARWAN NAAMANI/AFP/Getty Images
South Africa heading for defeat against Pakistan
Manzoor's maiden Test century puts Pakistan in control
20 most transparent companies; Tata Communications tops
South Africa could miss Steyn, Amla for 2nd Test vs Pak
Stats: Captain Dhoni rewrites record books