Dilshan returned unbeaten on 115 and Sangakkara made 91 during a record partnership of 184 runs to steer the hosts past South Africa's 238 all out in the 44th over of the day-night match. (Agencies)
The emphatic victory by the 2011 World Cup finalists reduced Wednesday's fifth and final match in Colombo to a formality.
Dilshan's 17th one-day century and the second against South Africa was studded with 16 boundaries. Sangakkara kept pace with his partner with eight fours and two sixes.
The pair put on Sri Lanka's highest one-day stand for any wicket against the Proteas after opener Mahela Jayawardene had been removed for 12 in the 10th over.
Left-handed Sangakkara missed his second hundred in the series when he holed out in the deep off Morne Morkel when just 10 more were needed for victory.
Ragged South Africa paid dearly for conceding 20 extras that included 17 wides and a no-ball.
Earlier, JP Duminy hit 97 and a fit-again Hashim Amla made 77 to lift South Africa to 238 after the tourists won the toss and elected to bat.
But the Proteas undid a good start by losing eight wickets for 87 runs after cruising at 118-1 in the 22nd over.
Duminy lashed seven boundaries and two sixes before he was last man out in the 49th over, bowled by unorthodox spinner Ajantha Mendis three runs short of a century.
Mendis finished with four for 51, while sling-arm fast bowler Lasith Malinga claimed three for 52 and Dilshan took two wickets.
Amla, batting for the first time in the series after being injured while fielding in the only other game he played, anchored the start with a fluent half-century that contained nine boundaries.
Duminy shared a second-wicket stand of 101 with Amla after Quinton de Kock had been bowled by Malinga in the third over.
Dilshan returned unbeaten on 115 and Sangakkara made 91 during a record partnership of 184 runs to steer the hosts past South Africa's 238 all out in the 44th over of the day-night match.