Pakistan made a ideal start to the fourth day when legspinner Yasir Shah became the quickest bowler to reach 200 test wickets by dismissing nightwatchman Will Somerville for 4.
However, Pakistan's three dropped catches, two of them comparatively hard, would hurt them if New Zealand go on to draw the Test and walk away with a drawn three-match series.
New Zealand, resuming at 26 for 2 on Thursday, fell to 37 for 3 after Yasir removed Somerville and were still needing 37 runs to make Pakistan bat again.
Following Grimmett and Ashwin, Australia's Dennis Lillee (38 Tests), Pakistan's Waqar Younis (38 Tests) and South Africa's Dale Steyn (39 Tests) held the top five spots in the list of fastest to 200 wickets before Yasir Shah achieved the milestone.
Since taking seven wickets on debut against Australia in 2014, Yasir has been a key figure in Pakistan's Test team. "The wicket is slow but it is turning from the patches".
It was a smart declaration - giving Pakistan enough temptation to chase for the victory, but some brilliant bowling made sure they never got close. "That is what we are going to try as there is still one full day left in the match".
Ross Taylor's (22 off 14 balls) over aggressive approach ultimately led to his downfall when he was caught in the deep as New Zealand slumped to 4-60.
WashPost: Ocasio-Cortez Claim About Pentagon Wrong
House interns fare worse: Only 8 percent of those who work for Republicans and 3.6 percent who work for Democrats get paid. She has also pledged to pay her interns at least $15 an hour , higher than most other elected representatives in Congress.
But they were undone by Williamson's masterclass and an innings from Nicholls that grew in confidence but, like his partner, enjoyed a touch of luck.
But Shah dropped Williamson on 80 and 106.
Williamson, who scored 89 in the first innings, drove medium pacer Hasan Ali to the cover boundary for his 12th four to complete a well deserved 19th Test century - his second against Pakistan.
Nicholls survived another chance on 9 when he successfully overturned an lbw decision against him off Shah's sharp turning delivery from round the wicket. He has so far hit eight boundaries.
On Day four in Abu Dhabi, Yasir has been extremely consistent with his lines, attacking the stumps in the 3rd innings.
He has taken 114 of his 200 wickets on spinner-friendly wickets in the United Arab Emirates in 17 Tests.
His wicket triggered a Pakistan collapse as they went from 304-5 to 348 all out with Somerville ripping up the tail after tea to finish with figures of 4-75.
Earlier, New Zealand declared their second innings on 353-7 after some 45 minutes of batting with Henry Nicholls remaining unbeaten on 126 and Williamson dismissed at his overnight score of 139.