After setting Sri Lanka a 386-run victory target in the bowler-dominated weather-hit contest, India needed seven wickets on the final day to gift Virat Kohli his first series victory since becoming the test captain.
Sri Lanka skipper Mathews (110) and debutant Kusal Perera (70), however, refused to throw in the towel at the Sinhalese Sports Club.
The duo resisted India’s victory push for more than 38 overs with gritty defiance but 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 new ball, dismissed Mathews in the first over after the break to rattle the hosts who eventually folded for 268.
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 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 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 as India went on to win their first test series in Sri Lanka since 1993.
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.