Sri Lanka 227 (Mathews 47, Samaraweera 76, Southee 5-62, Boult 4-42) and 47 for 4 (Southee 2-19, Bracewell 2-5) need a further 316 runs to beat New Zealand 412 and 194 for 9 dec (Taylor 75, Astle 35, Herath 3-67)
Scorecard and ball-by-ball details

In an intriguing day's Test cricket, in which 17 wickets fell, New Zealand left the hosts tottering with the top four back in the pavilion chasing a challenging 363 on the last day at the P Sara Oval. Fortunes ebbed and flowed but it was New Zealand who started and ended the day on a high. After wrapping up the Sri Lanka innings early, their top order was jolted and their plans of piling on a big lead before declaring took a hit. A fighting stand frustrated Sri Lanka and the declaration did come after tea, but the seamers were back in business, leaving Sri Lanka to battle for survival going into the fourth day.

New Zealand captain Ross Taylor needed sufficient time to try and bowl Sri Lanka out, keeping in mind the time lost due to the elements over the first three days. The declaration came shortly after tea, and with the light still good, New Zealand looked to create early pressure. They had success in the first ball of the innings when Tharanga Paranavitana shuffled too far across to Tim Southee and exposed his leg stump, departing for his third first-ball duck in Tests. Sri Lanka's hopes of chasing the target rested on an aggressive start from Tillakaratne Dilshan but, after making a start, he fell off a loose drive to the same bowler.

Kumar Sangakkara, out of sorts in the series, was also guilty of shuffling at the crease and only managed to play on to his stumps off the thigh, giving Doug Bracewell his first wicket. He found time to squeeze in another, and make perhaps the most important breakthrough, when he had Mahela Jayawardene poking at a delivery he should have left. Bracewell, whose stock delivery is just short of a length, got his line right to Jayawardene. He was guilty of straying too wide of off stump in both Tests, but on this occasion got it closer to the off stump.

Coming in to this Test on the back of five consecutive defeats, New Zealand needed to rely on their strengths - seam bowling - to reverse their horror run. The seamers set it up first thing in the morning, nipping out the last four wickets in just 7.4 overs to take a healthy first-innings lead of 168. Southee completed his third five-wicket haul but the bowler who inflicted the maximum damage was Trent Boult, who swung the new ball and dismissed the set overnight pair of Thilan Samaraweera and Suraj Randiv to finish with 4 for 42.

Samaraweera failed to add to his overnight score when he was squared up by a peach from Boult, which left the right-hand batsman late after pitching on middle stump, the outside edge taken by Martin Guptill at second slip. Boult struck again in his following over with one that swung in late and struck the base of Randiv's pads. Nuwan Kulasekara then edged Southee to first slip to give the bowler his second five-for in three matches. A display of brilliance sealed the innings as Kane Williamson pulled off a blinder, diving to his left at gully to catch a thick outside edge to get rid of Herath.

Behind by 168, Sri Lanka needed to win at least one session to put the pressure right back on the visitors. They got rid of the openers before lunch and picked up three more, in four balls, after the break. It left Taylor with the debutant Todd Astle to muster as much as they could to regain control.

New Zealand at that stage were leading by 243 with five wickets in hand. Taylor's presence was always New Zealand's safety net, fresh off a century in the first innings, but Astle's approach was what allowed the stand to flourish. Rather than get bogged down, he was positive, pulling Nuwan Kulasekara over square leg or his first boundary and using his feet to Herath, lofting over midwicket.

Taylor displayed the same patience that earned his first-innings ton, staying watchful and picking the singles and allowing Astle to go after the bowling. Being naturally aggressive, it was ironic that Taylor's first boundary came off his 77th ball, when he drove Randiv past cover to bring up his fifty.

Astle had his moments of fortune, when he was let off at slip by Paranavitana, though it was a tough chance. He also survived a run-out at the striker's end, though bizarrely the umpire Nigel Llong did not referred it, nor did the fielders appear interested in appealing.

With the lead going past 350, Sri Lanka's chances receded. They will need Samaraweera to lead the way again, under pressure, with Angelo Mathews for company. Six more wickets will give New Zealand their first win in Sri Lanka since 1998.

Kanishkaa Balachandran is a senior sub-editor at ESPNcricinfo