COLOMBO New Zealand were within sight of their first test victory in Sri Lanka in 14 years after 17 wickets fell on a thrilling penultimate day of the series on Wednesday.
The Black Caps set Mahela Jayawardene's side 363 for victory after first bowling them out for 244 and making 194 for nine declared in their second innings.
By stumps Sri Lanka had slumped to 47 for four as New Zealand dismissed Tharanga Paranavitana (0), Tillakaratne Dilshan (14), Kumar Sangakkara (16) and Jayawardene (5).
New Zealand went into the match on the back of five successive losses, their worst run in 57 years. Their last win in Sri Lanka was in 1998 and they were thrashed in the first test of the series in Galle, losing by 10 wickets inside three days.
But thanks to fast bowlers Tim Southee, Trent Boult and Doug Bracewell, along with captain Ross Taylor, they set up the chance of a rare win.
"We are well aware of the history," coach Mike Hesson told reporters. "Results don't lie and five (losses) in a row is hard to take.
"I'm delighted we have been able to string together four good days but clearly we have still got a lot of work to do and tomorrow is a huge day for us.
"We have continued to bowl well and I thought we bowled well in Galle too with the young seamers and they stood up again tonight.
"It was nice to get the three big boys out (Dilshan, Sangakkara and Jayawardene) tonight but we know we are going to have to work for every one of those six wickets and it could take us until 5 o'clock (on Thursday)."
The day began with superb spells by Southee (five for 62) and Boult (four for 42) as New Zealand took the home side's final four wickets for 19 runs after they had resumed at 225 for six.
The stubborn Thilan Samaraweera top-scored with 76 but he failed to add to his overnight total before being caught at second slip by Martin Guptill off Boult to give the left-armer his 100th first-class wicket.
Boult also removed overnight batsman Suraj Randiv (39), lbw to an excellent inswinger, and claimed the final wicket when he had Rangana Herath (5) brilliantly caught in the gully by Kane Williamson.
Southee weighed in with the wicket of Nuwan Kulasekara (6), caught at first slip by Ross Taylor, to record his first five-wicket haul of the series.
That gave New Zealand a first-innings lead of 168 but when they slumped to 75 for five just after lunch, including the loss of three wickets in four balls, their dreams of levelling the series appeared on rocky ground.
They were rescued by Taylor, who followed up his first innings 142 with a patient 74 from 95 balls, including only two fours, the first of which he struck to bring up his half-century.
The captain found a willing ally in debutant Todd Astle, who made a resourceful 35 as the pair added 97 for the sixth wicket.
"There were some jitters straight after lunch," said Hesson. "It was important not to look too far ahead and Ross was extremely composed while Todd backed his own game to produce a crucial partnership for us."
Herath was again the most successful bowler for Sri Lanka and finished with three for 67 to give him nine wickets in the match and 20 in the two-test series.
Sri Lanka were left with an awkward period to negotiate before bad light set in and in that time Southee (two for 19) and Bracewell (two for five) created havoc.
Southee removed Paranivitana first ball, lbw to a swinging delivery, and had Dilshan driving airily and edging to wicketkeeper Kruger van Wyk.
Then Bracewell got in on the act as Sangakkara played on before Jayawardene pushed tamely at another Bracewell delivery to edge to Van Wyk.
Samaraweera was unbeaten on one at the close with Angelo Mathews also on one and Sri Lanka needing a miracle to prevent a New Zealand victory.
(Editing by Ed Osmond)