bat out a major part of the afternoon session and lift the hosts to 249-6 by tea.
Mathews made 110, his seventh Test century and the second in successive matches after scoring 102 in the second Test, before he was trapped leg-before to Sharma in the first over after tea with the second new ball.
Left-handed Perera followed his 55 in the first innings with 70, becoming only the second Sri Lankan after Dinesh Chandimal to score two half-centuries in his debut Test.
Perera looked set for a bigger score when he was dismissed shortly before tea, playing a reverse sweep off Ashwin straight to Rohit Sharma at point.
India grabbed the last five wickets for 26 runs after Sri Lanka were sailing at a comfortable 242-5 before Perera’s dismissal.
Sri Lanka began the final session with a reasonable hope of surpassing the difficult target — needing 137 runs more with a possible 36 overs remaining — but India tightened the screws after tea to emerge victorious.
Mathews said he was disappointed after gaining the advantage of winning the toss and asking India to bat first on a seaming wicket.
“We got them to bat in demanding conditions, that is why we are very disappointed at losing,” he said.
Score Board
Sri Lanka won toss
India 1st innings 312 all-out (C Pujara 145; Prasad 4-100)
Sri Lanka 1st innings 201 all-out (M Perera 55; I Sharma 5-54)
India 2nd innings 274 all-out (R Ashwin 58; Pradeep 4-62)
Sri Lanka 2nd innings
W U Tharanga c Ojha b I Sharma 0
J K Silva c Pujara b Yadav 27
F D M Karunaratne c Ojha b Yadav 0
L D Chandimal c Kohli b I Sharma 18
*A D Mathews lbw b I Sharma 110
H D R L Thirimanne c Rahul b Ashwin 12
†M D K J Perera c R Sharma b Ashwin 70
H M R K B Herath lbw b Ashwin 11
P H T Kaushal not out 1
K T G D Prasad c Binny b Ashwin 6
N Pradeep lbw b Mishra 0
Extras (b 4, lb 2, nb 7) 13
Total (all out; 85 overs) 268
Fall: 1-1, 2-2, 3-21, 4-74, 5-107, 6-242, 7-249, 8-257, 9-263, 10-268
Bowling: I Sharma 19-5-32-3 (4nb); Yadav 15-3-65-2; Binny 13-3-49-0; Mishra 18-1-47-1 (3nb); Ashwin 20-2-69-4
Result: India won by 117 runs
Series: India won the 3-match series by 2-1
Test debuts: N V Ojha (India); M D K J Perera (Sri Lanka)
Man of the Match: C A Pujara (India)
Man of the Series: R Ashwin (India)
Umpires: N J Llong (England) and R J Tucker (Australia). TV umpire: R R Wimalasiri. Match referee: A J Pycroft (Zimbabwe)