Angelo Mathews's resilience could not deny New Zealand their first Test victory in Sri Lanka in 14 years, as the visitors won the second Test by 167 runs to level the two-match series on Thursday.
Mathews struck a defiant 84 and resisted the New Zealand attack before being the last man out as Sri Lanka, resuming on 47 for four, folded for 195 runs 25 minutes after tea.
The victory also ended New Zealand's five-match losing streak, their worst in 57 years.
"It was good to win after losing so comprehensively in Galle," New Zealand skipper Ross Taylor said, referring to his team's 10-wicket defeat inside three days in the first Test.
"We got a lot of stick in the week leading up to this match but we were very determined to get a competitive total.
"Test match wins away from home don't happen very often, so we will enjoy this and hopefully get some momentum going forward," he said.
His Sri Lankan counterpart Mahela Jayawardene blamed the top order batsmen for the defeat.
"We lost wickets up front and so the momentum was not there. Credit to New Zealand as they bowled well throughout the series with the new ball," he said.
Sri Lanka slipped to 63 for five soon after the resumption on the final day when Thilan Samaraweera (seven) was run-out after a horrible mix-up with Mathews.
Vice-captain Mathews batted for exactly five hours before being caught at second slip by Martin Guptill off the bowling of left-arm fast bowler Trent Boult (three for 33).
Mathews hit 11 fours and an on-driven six off Jetan Patel's off-spin and faced 228 deliveries.
Mathews and Prasanna Jayawardene (29) resisted together for 35 overs before Jayawardene became leg-spinner Todd Astle's first wicket at the highest level.
Suraj Randiv, who resisted for three hours in the first innings on his way to a Test-best score of 39, failed to score in the second, edging Boult to Guptill at second slip.
Sri Lanka were still fighting at tea as Mathews and Nuwan Kulasekara (18) resisted for an hour up to the final interval but the end came quickly after that break, aided by the second new ball.
Kulasekera fell in the first over of the final session, caught by Kane Williamson in the gully off Boult.
In the next over, Tim Southee (three for 58) removed the scoreless Shaminda Eranga for his eighth wicket of the match when Williamson took a brilliant low, right-handed catch, his fifth of the match.
"Tim Southee and Trent Boult led the attack throughout the whole series, they were very consistent and we fed off them," said Taylor.
Taylor was adjudged player of the match for his knocks of 142 and 74, while Herath was named player of the series after taking 20 wickets, including 11 in Galle.
New Zealand (1st innings): 412
Sri Lanka (1st innings): 244
New Zealand (2nd innings): 194-9 declared
Sri Lanka (2nd innings): (overnight 47-4)
T. Paranavitana lbw b Southee 0
T. Dilshan c Van Wyk b Southee 14
K. Sangakkara b Bracewell 16
M. Jayawardene c Van Wyk b Bracewell 5
T. Samaraweera run out 7
A. Mathews c Guptill b Boult 84
P. Jayawardene c Van Wyk b Astle 29
S. Randiv C Guptill b Boult 0
N. Kulasekara c Williamson b Boult 18
S. Eranga c Williamson b Southee 0
R. Herath not out 6
Extras: (b-4, lb-11, w-1) 16
Total: (all out; 85.5 overs) 195
Fall of wickets: 1-0, 2-35, 3-41, 4-46, 5-63, 6-119, 7-122, 8-168, 9-169.
Bowling: Southee 20-5-58-3, Boult 17.5-6-33-3, Bracewell 13-6-13-2 (1w), Patel 16-7-20-0, Astle 18-4-56-1, Flynn 1-1-0-0.
New Zealand won by 167 runs.
Man of the match: Ross Taylor
Man of the series: Rangana Herath
Two-match series drawn 1-1.