AB de Villiers played a captain's knock of 51, but could not prevent South Africa from being condemned to their 13th defeat in 15 one-dayers on Sri Lankan soil.
The tourists were struggling at 137-8 when Ryan McLaren hit 29 and Aaron Phangiso an unbeaten 18 down the order to boost the total.
Seamer Suranga Lakmal and off-spinner Sachithra Senanayake marked their first appearance in the series by sharing five wickets.
Ajantha Mendis claimed three for 36.
Opener Dilshan, who hit an unbeaten 115 in the fourth game in Pallekele on Sunday, plundered 13 boundaries before he was bowled for 99 by McLaren in the 39th over.
"I am a bit disappointed at missing my century, but these things happen in cricket," said Dilshan.
"But I think McLaren bowled that over very well.
"I am really enjoy