Williamson's 200 not out in 10 hours earned New Zealand a meaningful 174-run lead as the visitors declared at a monumental 612-9 at tea, with tailender Ish Sodhi scoring a career-best 65.
New Zealand spinners Michael Bracewell and Ish Sodhi made early inroads in the final session to reduce Pakistan to 77-2 at stumps. Pakistan still trails by 97 runs on a wicket which has some encouragement for spinners from the bowlers' footmarks.
Imam-ul-Haq saw off the session with an unbeaten 45 while nightwatchman Nauman Ali survived an umbrella of fielders around him in the last over to go not out on 4.
Abdullah Shafique once again threw away his wicket as he was caught low down at short mid-on for 17 after attempting a needless drive against off-spinner Michael Bracewell.
Shafique had fallen cheaply in Pakistan's first innings score of 438 when he came down the wicket off Ajaz Patel in only the fourth over of the game and got stumped. Lefthander Masood was out lbw for 10 after he went onto the backfoot against Sodhi's sharp delivery.
Captain Tim Southee ended Pakistan's long frustrating time in the field when he declared just after Williamson lifted mystery spinner Abrar Ahmed over extra cover for his 21st boundary and then raised his fifth double-hundred with a single that also featured a six.
Abrar, who took 17 wickets in two test matches against England earlier this month, finished with 5-205 but not before Williamson and Sodhi had extended the lead with a 159-run seventh-wicket stand on a slow turning wicket.
Williamson and Sodhi dug in for well over 1 1/2 hours into the second session after New Zealand resumed on 440-2 before Pakistan claimed three quick wickets through spinners.
Both put on 79 runs in the first session and batted with determination even when Pakistan took the second new ball. They stood firm against the googlies and leg spin of Abrar while left-arm spinner Nauman (3-185) couldn't pose a problem from the footmarks.
Sodhi finally holed out soon after crossing his previous test best of 63 – also against Pakistan in 2014 – while Southee and Neil Wagner followed without scoring.
Williamson was on 186 when last man Ajaz Patel walked in but went into the 190s with a straight six over the head of Abrar before eventually reaching his second double hundred against Pakistan in a 395-ball knock.
It was Williamson's first international score of over 100 in almost two years since he made 238 against Pakistan at Christchurch in January 2021.
Williamson fully capitalized on two stumping chances early in his innings and also twice successfully overturned on-field lbw rulings against him through television referrals as Pakistan rued the missed opportunities.
Sodhi batted with a lot of patience and hit three boundaries against seamer Mir Hamza on the off side of the wicket after Pakistan took the third new ball.
Hamza, also making a comeback after playing his only previous test against Australia in 2018, could have had his first wicket in the penultimate over before the break, but Pakistan didn't appeal as the TV replays suggested he got a thin outside edge of Sodhi's bat.
New Zealand's lead was 24 when Nauman came close to dismissing Williamson on 116 in his second over of the day.
But Williamson quickly went for a successful television referral against umpire Aleem Dar's lbw ruling after he missed a full-length delivery down the legside and the TV replays suggested the ball had pitched outside the off stump.