New Zealand won by 167 runs, bowling Sri Lanka out for a second innings total of 195 in the last session of the fifth and final day at the P. Sara Oval as the hosts chased a 363-run target.
All-rounder Mathews offered stiff resistance to the tourists, top-scoring with a fighting 84 which included one six and 11 fours. He was the last man dismissed after batting for more than two sessions.
New Zealand, who had lost five successive Tests before this match, put in an improved all-round show in Colombo, posting 412 in the first innings and their bowlers, especially the pacemen, delivered in both innings.
The tourists tightened their grip on the match on Wednesday when they reduced the hosts to 47-4, but had to work hard for success on a fifth-day wicket, which was still good for batting.
New Zealand got just one wicket in the morning session and two in the second before completing the job with the second new ball in the evening.
Fast bowlers Trent Boult and Tim Southee each finished with three wickets, while paceman Doug Bracewell took two and debutant leg-spinner Todd Astle one.
Astle provided the crucial breakthrough in the afternoon when he had Prasanna Jayawardene (29) caught behind with a delivery that turned and bounced for his first Test wicket.
Jayawardene was involved in a defiant 56-run stand for the sixth wicket with Mathews.
Boult, who got four wickets in the first innings, had lower-order batsman Suraj Randiv caught by Martin Guptill at second slip before ending the innings with the wicket of Mathews, caught by the same fielder in the slips.
Mathews and wicket-keeper Jayawardene took no risks during their stand after their team lost the big wicket of Thilan Samaraweera in the opening hour -- run out after a mix-up with Mathews.
Samaraweera, who top-scored in the first innings with 76, had added just six to his overnight one.
Sri Lanka won the opening Test by 10 wickets in Galle.