Set 176 to claim the Test, Pakistan appeared to be crusing at 40 without loss.
But Ajaz Patel sparked the first flurry of departures. The spinner accounted for Imam-ul-Haq for 27 and Ish Sodhi claimed the scalps of Mohammad Hafeez and Haris Sohail.
But from 48 for 3, Pakistan appeared to have recovered their nerve as Azar Ali and Asad Shafiq took them past 100.
But Neil Wagner broke up the partnership when Shafiq, on 45, edged his delivery to wicketkeeper BJ Watling.
That made it 130 for 4 and Pakistan imploded. An ill-judged single led to Babar Azam's run out and three more wickets fell with just eight runs added.
Azar Ali was the last man out for 65 with the second innings score on 171. "It certainly was dramatic," said Williamson. "Throughout the four days both teams were put under pressure. I think at the end of the day it was a great advertisement for Test cricket."
Williamson, who now has nine wins in his 18 Tests in charge, described the victory as one one of his best. "The wicket was challenging and both teams had to fight hard and certainly Pakistan had the upper-hand.
"To get through Pakistan in four days and come out with this result must obviously rank as one of our best wins.
"I think the fighting attributes of this team really shone through and it's important to build on a number of parts to go in to the next game"
The second Test in the three match series starts in Dubai on 24 November. "We have given away soft wickets," said Pakistan captain Sarfraz Ahmed. "Nobody played a long innings. It is very disappointing to say the least."