Kusal Mendis made a fighting half-century
New Zealand were eyeing an historic victory as injury and a barrage of Neil Wagner bouncers left Sri Lanka in tatters at the close of day four of the second Test in Christchurch on Saturday.
Sri Lanka were 231 for six at stumps, 429 runs short of their improbable 660-run target, with doubt whether the injured Angelo Mathews would return.
At the crease were Dilruwan Perera on 22 and Suranga Lakmal on 16.
Wagner, who had enjoyed little success in the series, broke through stubborn Sri Lankan resistance to have figures of three for 47.
After rain ensured a drawn first Test in Wellington, a win in the Christchurch decider would give New Zealand a fourth consecutive series win for the first time after beating the West Indies, England and Pakistan earlier this year.
Despite losing both openers in the first two overs of their second innings, Sri Lanka fought to stay in the game until short-ball specialist Wagner came into the frame.
Skipper Dinesh Chandimal and Kusal Mendis produced stubborn resistance for 53 overs for the third wicket before Mendis went for 67.
They had seen off the swing and seam of New Zealand strike bowlers Tim Southee and Trent Boult at the start of the day, were untroubled by spinner Ajaz Patel, and initially they dodged the barrage aimed at the ribs by Wagner.
Wagner's first success came when he changed tack and lured Mendis into a false sense of security.
Mendis, who in the course of his innings became only the second player behind India's Virat Kohli to score 1,000 runs this year, was frustrated as Wagner forced him on to the back foot with successive deliveries.
When the next ball was full length, the 23-year-old could not resist going for the drive and was smartly caught by substitute fielder Matt Henry diving to his left at extra cover.
Angelo Mathews, who in the first three innings of the series scored 236 runs and was dismissed only once, reached 22 when he was forced to retire at tea with a hamstring injury.
He pulled up lame running between the wickets about 10 minutes before the interval and could only hobble after that.
Angelo Mathews (C) seeks medical assistance during day four of the second cricket Test match between New Zealand and Sri Lanka at Hagley Park Oval in Christchurch on December 29, 2018.
Chandimal faced 228 deliveries before he fell victim to a Wagner bouncer that zipped from the glovers to the helmet and into the hands of the close-in fielder Henry Nicholls.
Niroshan Dickwella batted freely for 19 until the new ball was taken and he chopped a wide Southee delivery on to his stumps.
Silva and Dilruwan Perera took Sri Lanka past the 200 mark before Wagner struck again with Silva caught behind for 18.
Wagner also clouted Perera on the helmet with a rising delivery just before stumps but the batsman was able to play on after being checked by medical staff.
New Zealand first innings 178 (T. Southee 68, B. Watling 46; Lakmal 5-54)
Sri Lanka first innings 104 (A. Mathews 33no; Boult 6-30, Southee 3-35)
New Zealand second innings 585-4 dec (T. Latham 176, H. Nicholls 162no, C. de Grandhomme 71no, J. Raval 74; Kumara 2-134)
Sri Lanka second innings (overnight 24-2)
D. Gunathilaka c Watling b Southee 4
D. Karunaratne c Watling b Boult 0
D. Chandimal c Nicholls b Wagner 56
K. Mendis c sub (Henry) b Wagner 67
Mathews retired hurt 22
R. Silva c Watling b Wagner 18
N. Dickwella b Southee 19
D. Perera not out 22
S. Lakmal not out 16
Extras: (b 4, lb 2, wd 1) 7
Total: (for 6 wickets, 104 overs) 231
Fall of wickets: 1-1 (Karunaratne), 2-9 (Gunathilaka), 3-126 (Mendis), 4-158 (Chandimal), 5-181 (Dickwella), 6-208 (Silva)
Bowling: Boult 27-11-73-1, Southee 27-13-61-2, de Grandhomme 10-1-23-0 (1w), Wagner 28-10-47-3, Patel 12-9-21-0