Batsman Tom Latham produced another masterful innings as New Zealand moved into a commanding position over Sri Lanka heading into day four of the second and final test at Hagley Oval in Christchurch.
The 26-year-old left-handed opener was dismissed for 176 in the final over before tea, having batted for more than nine and a half hours, faced 370 balls and guided his side to a second-innings lead in excess of 500.
Captain Kane Williamson declared the second innings about an hour after the interval on 585 for four, leaving the visitors needing to score a world record 660 to win the match and two-test series 1-0 after the first test ended in a damp draw.
The highest fourth innings total to win a test was the 418-7 that West Indies achieved against Australia in Antigua in 2003.
Sri Lanka's victory target was made all the more difficult when opening batsmen Dimuth Karunaratne (0) and Danushka Gunathilaka (4) were dismissed in the first two overs.
Captain Dinesh Chandimal, who was on 14, and Kusal Mendis (6) saw them through to 24-2 at stumps and needing to score another 636 runs to win the match and series or bat two further days to save both.
The hosts' strong position was testament to Latham, who dominated their second innings, despite a fourth test century from Henry Nicholls (162 not out) and New Zealand's fastest test half-century from 28 balls by Colin de Grandhomme (71 not out) as they chased quick runs after tea.
Latham also scored a career-best 264 not out in New Zealand's only innings in the first test in Wellington, batting for more than 11 and a half hours and facing 489 deliveries.
It has been a superb return to form for the 26-year-old, whose place in the side while probably not under serious threat, had begun to be questioned after a lean run of form.
Since he notched 177 against Bangladesh in early 2017 he had scored a total of 488 runs in 19 innings at an average of 27.11.
In his three innings in the current series, he has scored 450 runs at an average of 225 and anchored several fruitful partnerships in New Zealand's massive totals of 578 in the first game and 585-4 in Christchurch.
He brought up his eighth test century, and first on his home ground, when he cut Suranga Lakmal to the fence for his ninth boundary, but fell just short of a second double-ton, feathering a catch down the leg side to wicketkeeper Niroshan Dickwella.
Latham was ably supported by Nicholls, who surpassed his previous highest test score of 145 not out shortly before the declaration.