The 32-year-old scored a 90-ball 107 with a six and 10 fours to anchor Pakistan’s 305 in 49.5 overs, before skipper Shaheen Shah Afridi grabbed 3-55 to keep Sri Lanka down to 268 in 48.1 overs.
The hosts now play England in the second match on Tuesday — also in Rawalpindi — in the series seen as a build-up for next year’s 50-over World Cup in southern Africa.
Pavan Rathnayake (79) and Janith Liyanage’s 60 kept the visitors in the chase during a fighting 119-run fifth wicket stand.
Opener Kamindu Mendis also contributed with a fluent 44.
Rathnayake cracked two sixes and six boundaries while Liyanage’s knock had five boundaries, but once both fell only Dasun Shanaka (28) really troubled the scorers as Sri Lanka lost their last five wickets for just 15 runs.
Naseem Shah, Haris Rauf and Faheem Ashraf chipped in with two wickets apiece for Pakistan.
Earlier, Agha, coming out of a miserable last three months, propelled Pakistan to victory.
He was sent home ahead of the third Test in England in August after captaining the team in the first match.
“These times come on you and I thought that I will go back in domestic cricket and make things right with my performances,” said Agha, who was also sacked as Pakistan’s T20I captain.
“I was looking to hit the ball in the pockets to rotate the strike so that we can take our team beyond 300 so we batted aggressively in the end.”
Agha hit two consecutive boundaries off pacer Asitha Fernando to complete his fourth one-day international hundred, finally falling to the same bowler in the 47th over.
He added 97 runs for the fifth wicket with Hasan Nawaz (37) and another 64 for the sixth with Arafat Minhas, who made 18.
Left-arm pacer Dilshan Madushanka had jolted Pakistan with the wickets of openers Saim Ayub (seven) and Fakhar Zaman (16).
Debutant Saad Baig scored a brisk 40-ball 39 with two sixes and three fours.
Along with Babar Azam (45), the pair lifted the score during their 74-run stand.
Fast bowler Eshan Malinga dismissed both in successive overs to halt Pakistan’s progress before Agha came into his own.
Malinga was the pick of the Sri Lanka bowlers with a career-best 4-46, while Fernando took 3-59.

