Sri Lanka made 1-120 to win by nine wickets.
Fast bowler Dushmantha Chameera, sidelined for eight months by an ankle injury, took 4-63 to be named player of the match, and six wickets in two matches to be named player of the series in his comeback.
He missed the first ODI.
Fellow quick Lahiru Kumara dismissed both openers and Chameera took out four of the top six batters. Legspinner Wanindu Hasaranga finished with three wickets after Afghanistan chose to bat first.
Afghanistan were all out in 22.2 overs. It was a poor effort on a good batting surface. Only three batters managed 20-plus runs with too many soft dismissals.
Afghanistan lost opening batter Rahmanullah Gurbaz early again, trying to hook Kumara in the second over and top-edging to fine leg on eight.
Chameera got Rahmat Shah and Hashmatullah Shahidi out in the same fifth over, both to nicks, and Afghanistan were reduced to 6-77 with little resistance from the tail against the spinners.
Mohammad Nabi top scored with 23.
Sri Lanka wasted no time in chasing down the target. Openers Pathum Nissanka and Dimuth Karunaratne shared an 84-run stand.
Nissanka raced to his seventh half-century in just 32 balls with eight fours and two sixes. He was trapped on 51.
Karunaratne required 43 balls for his eighth half-century that included seven fours. Karunaratne was unbeaten on 56 when Sri Lanka secured the win with 34 overs to spare.
It was a good comeback from Sri Lanka after losing the first game by six wickets. The hosts won the second game by 132 runs and sealed the series with a nine-wicket win. It was their first come-from-behind series victory since 2014.
After successive half-centuries in his first ODI series in more than two years, Karunaratne appears to have secured a spot for the World Cup qualifiers that begin in Zimbabwe next week.
Afghanistan are already through to the Cricket World Cup in India in October.