They won it on the back of an outstanding, aggressive bowling performance, in which legspinner Imran Tahir, who won man of the match for his four for 26, and part time offspinner JP Duminy, who took a hat-trick in snaring three for 29, befuddled the Sri Lankans.
But the fast trio of Dale Steyn, Morne Morkel and Kyle Abbott corralled the Sri Lankan batsmen early, didn't let them settle and had them on the run from the start before dismissing them for 133 in the 38th over.
They were backed by outstanding fielding, and opener Quinton de Kock put a run drought behind him to secure the win with a rousing unbeaten 78 off 57 balls.
The loss marked the end of the international career of two Sri Lankan champions Mahela Jayawardene and Kumar Sangakkara, who was unable to maintain his fine World Cup run of four successive centuries.
''The guys were very motivated for the game. I had a good feeling coming into the ground.
''The guys were in a good space, we really rocked up mentally and I'm really proud of what the guys did," de Villiers said.
They now face either New Zealand, who have won all six group games at the cup, or the West Indies, hot and cold but always a threat, in the first semifinal in Auckland next Tuesday.
Four years ago New Zealand beat the South Africans in an emotional quarter-final in Dhaka, defending 221.
South Africa easily won two of three ODIs on their short trip to New Zealand in October - the third was a washout. They will feel confident whichever team they face.
They won't know the identity of their semifinal opponent until Saturday night, when New Zealand and the West Indies clash in Wellington.
There was much to admire in South Africa's performance, which was underpinned by an aggressive mindset in all three skills.
The big threat for Sri Lanka was expected to come from the fast bowlers.
But while Steyn, Morkel and Abbott did their business impressively, Tahir and Duminy removed four batsmen for just two runs to end any hopes Sri Lanka had of putting up a remotely competitive total.
''I'm really pleased all my hard work paid off today," the extrovert Tahir said.
''We have great players and playing with them is a dream come true for me. It's a great feeling and that's what motivates me every day."
Tahir now has a share of second place in the leading cup wicket takers on 15, one behind Australia's Mitchell Starc.
Both the West Indies and New Zealand will have watched South Africa's performance with interest. They will have had confirmed for them that one of them faces a substantial challenge next week - once they get through Saturday's assignment first.