He is playing his first tournament since suffering serious injuries in a car accident in December 2022 that kept him out of last year's IPL as well as the 50-overs World Cup in India
Sri Lanka were reeling at 55-4 in the 12th over before Mathews (113) and Lahiru Thirimanne (53) added 124 runs to steady the innings.
Mathews' third one-day international century included 10 fours and two sixes.
Jasprit Bumrah struck two early blows and returned to dismiss Mathews in his 3-37 for India who have qualified for the semi-finals.