Facing a notional target of 363, the hosts began the final day in trouble on 47 for four and though Mathews made 84, only Prasanna Jayawardene and Nuwan Kulasekara offered any worthwhile support.
Tim Southee and Trent Boult took three wickets apiece as New Zealand bowled their opponents out for 195 to win by 167 runs. Doug Bracewell added two for 13 off 13 overs, claiming the prize scalps of Kumar Sangakkara and Mahela Jayawardene.
Having won the first Test in Galle by 10 wickets, Sri Lanka were focused solely on not losing this second match to earn a 1-0 series win.
The early run-out of Thilan Samaraweera this morning left the score at 63 for five but Mathews and Prasanna Jayawardene survived the rest of the morning session.
The pair took their side to 107 for five at lunch and their partnership totalled 56 before wicketkeeper Jayawardene (29) edged to opposite number Kruger van Wyk to give leg-spinner Todd Astle his first Test wicket.
Suraj Randiv failed to score but Mathews reached a dogged 178-ball half-century with his fifth boundary, hammered over midwicket off Astle, before repeating the dose next ball.
Nuwan Kulasekara hit Astle for two sixes in an over and Mathews lifted Jeetan Patel beyond the ropes but resistance was still the order of the day as Sri Lanka reached tea on 167 for seven.
But Kulasekara fell three balls after the restart for 18 and when Southee removed Shaminda Eranga without scoring for figures of three for 58, the tourists were on the cusp of a series-tying win.
Mathews went down swinging, hitting four boundaries in Southee's next over, but then edged Boult (three for 33) to Martin Guptill at second slip to end the match.
Follow us @SprtNationalUAE