Having set Sri Lanka a 386-run victory target in the bowler-dominated contest, India needed seven wickets on the final day to gift Virat Kohli his first series victory since becoming the test captain.
Mathews (110) and debutant Kusal Perera (70), however, were in no mood to oblige and they refused to throw in the towel at the Sinhalese Sports Club.
The duo resisted India’s victory push for 38 overs before wheels came off the Sri Lankan innings towards the end of the second session.
Perera succumbed to a rush of blood just before tea and Ishant Sharma, armed with the second new ball, dismissed Mathews in the first over after the break as the hosts eventually folded for 268.
“It’s never easy to come back one-nil down in the series, playing away from home, and in Sri Lankan conditions,” Kohli said at the presentation ceremony.
“The kind of attitude and the character the team has shown, I’m proud of the boys,” he said after India recorded their first test series win in Sri Lanka since 1993.
“It feels nice to have created a bit of history, especially with such a young team… It’s a magnificent milestone for us to build on and gain confidence from,” added Kohli.
Resuming on 67-3, Sri Lanka lost two wickets in the morning session before the 135-run stand between Mathews and Perera not only halted India’s victory bid but also rekindled faint home hopes of a miraculous win.
Mathews brought up his seventh test century in 217 balls, while Perera shone in his debut test as well, complimenting his first innings half-century with an aggressive 70.
The stumper-batsman, however, threw away his wicket, reverse sweeping Ravichandran Ashwin (4-69) to Rohit Sharma at point.
Ishant (3-32) then ended all home hopes by trapping Mathews leg before for his 200th test wicket.
“Our batting flopped again, to be honest,” Mathews said as Sri Lanka made a poor start to life after Kumar Sangakkara.
“The bowlers did a really good job throughout the test match. Out batters were not up to the mark.”
Cheteshwar Pujara, who struck an unbeaten 145 in the makeshift opener’s role for India, was adjudged man-of-the-match in the low-scoring contest, while Ashwin’s 21 wickets earned him the man-of-the-series award.
(Reporting by Amlan Chakraborty in New Delhi; editing by Sudipto Ganguly)