Williamson and Nicholls hit double tons as NZ punish Sri Lanka
The tourists had responded with 26-2 by the close of play at Wellington's Basin Reserve and face an uphill battle to avoid being swept in the two-match series after losing the first test by two wickets in Christchurch on Monday.
Williamson also scored a century, his 27th in tests, in the second innings of that match, but Saturday's magnificent effort in the company of Nicholls was an entirely different order of dominance.
After a rain-disrupted day one, Williamson resumed on 26 not out with his country 155-2 and barely put a foot wrong until he holed out in the deep in the late afternoon with 215 runs to his name.
The 32-year-old became the first New Zealand batsman to score 8,000 test runs as he marched to his sixth double century, pounding 23 fours and a couple of sixes in the 296-ball innings.
Nicholls pillaged runs at a slightly lower rate at the other end as he worked his way out of a recent form slump with his highest test score of 200 not out. It was the first time two New Zealand batsmen had scored double centuries in one innings.
Sri Lanka are not the first team to regret winning the toss and choosing to bowl on an apparent greentop only to watch the Black Caps batting for a couple of days.
Daryl Mitchell scored a quickfire 17 and Tom Blundell 17 not out after Williamson's departure as New Zealand swung the bat to inflate their tally before the declaration.
Seamer Lahiru Kumara (0-164) of the visiting bowlers suffered the most but Asitha Fernando and Kasun Rajitha were both also well into three figures in the debit column.
Matt Henry wasted little time in showing them how to bowl on the track, tempting opener Oshada Fernando into a push at the ball which Blundell gobbled up behind the wickets.
Doug Bracewell then celebrated his return to test cricket after a gap of nearly seven years with the wicket of Kusal Mendis, who departed for a duck after Doug Conway took a brilliant catch at point.
Skipper Dimuth Karunaratne, who was 16 not out, and nightwatchman Prabath Jayasuriya, unbeaten on four, will resume on Sunday with Sri Lanka a hefty 554 runs in arrears.