Seamer Tim Southee spearheaded a great fightback by New Zealand on day two of the first test against Sri Lanka to leave the match fascinatingly poised on Sunday.
Southee's four for 46 was crucial in helping to restrict the home side to a first-innings lead of 26 as they were bowled out for 247.
Although New Zealand then lost Brendon McCullum (13) in their second innings, they were still able to close on 35 for one - a lead of nine.
Southee started the day with a burst of three for 18 from seven overs and with Trent Boult (two for 46) at the other end providing excellent support, Sri Lanka were reduced to 50 for five having resumed at nine for one. The Kiwis made 221 first up.
"We were disappointed with our batting in the first innings and we knew the bowlers had to step up to get us back into the game," Southee told reporters.
"We had to make the most of the new ball as it was swinging, we put it in the right areas and deserved our wickets.
"The bowlers did an outstanding job and we have grabbed the game back and now I hope we can put up a decent total."
The fact Sri Lanka were able to secure a lead was due almost entirely to an outstanding partnership of 156 for the sixth wicket between captain Mahela Jayawardene (91) and his deputy Angelo Mathews (79).
Jayawardene, who became the second player after former New Zealand captain Stephen Fleming to top 1,000 runs in tests between the two sides, hit 11 fours and a six during a stay of 176 balls.
He was eventually dismissed gloving an attempted sweep off spinner Jeetan Patel (three for 55), well caught by the tumbling Kruger van Wyk behind the stumps.
It was the sixth time Jayawardene has been dismissed in the 90s in tests but he still had the satisfaction of extending his remarkable record at Galle, where he has scored 2,284 of his 10,631 test runs.
Mathews faced 154 balls and hit 12 fours and a six before edging a loose drive to become James Franklin's first test wicket since April 2009.
The sixth wicket stand occupied 49 overs and was in stark contrast to the chaos of the first hour of proceedings when wickets tumbled at regular intervals.
Southee struck with the third ball of the day when he dismissed Tharanga Paranavitana, bowled off the inside edge for a duck.
The bowler then had nightwatchman Suraj Randiv (9) caught by Martin Guptill at second slip the delivery after McCullum dropped a regulation edge at third slip.
Left-armer Boult then joined in by dismissing Kumar Sangakkara (5), who edged a perfectly pitched away-swinger to McCullum in the slips as the home side tumbled to 20 for four.
Thilan Samaraweera (17) and Jayawardene tried to see off Boult and Southee's onslaught but Samaraweera was eventually dismissed leg before wicket to Southee, offering no shot to a ball that seamed back into the right-hander.
Once Mathews was dismissed the innings subsided meekly with the final five wickets falling for 41 runs.
"We were hoping for a bigger lead but you can't be greedy after being 20 for four and 50 for five," said Sri Lanka coach Graham Ford.
"Credit to the New Zealand bowlers, they bowled fantastically well up front and it was a tough day for our batsmen.
"We looked like being a long way behind but a fantastic partnership between Mahela and Angelo got us right back into the game."