Karunaratne's display with the bat ensured Sri Lanka, first, posted a strong total on the board in their first innings, and then set up an nearly unbeatable target in the second.
South Africa were set a target of 352 runs to win the first Test on the third day after the hosts were bowled out for 190 runs in their second innings. With small but useful unbeaten contributions from Angelo Matthews (14) and Roshan Silva (10), Sri Lanka have reached a place in the match where they would have to do things drastically wrong not to win the match from here on in.
In their second innings, Dimuth Karunaratne - the centurion of the first innings - batted solidly yet again to score a steady 60.
Speaking after the defeat Du Plessis said: "It's just a case of our batters somehow trying to put pressure back on the quality of spin bowling that Sri Lanka have".
Suranga Lakmal has now won both Tests since stepping in to replace the suspended Dinesh Chandimal as captain, while South Africa must go back to the drawing board with the second Test starting in Colombo next Friday.
"What we have realized is that they don't play offspin too well", said Perera, who took 16 wickets in the 2014 series.More news: We're not heroes, says British diver who led Thai cave rescue
Host nations don't always provide their most sporting tracks for these fixtures.
Offspinner Dilruwan Perera finished with his best match figures of 10 for 78 after taking 6 for 32 in the second innings while Rangana Herath leapt to ninth on the all-time wicket-takers' list with his 3 for 38. With a first-innings lead of 161 runs, it was feeling comfortable on a wicket that was offering assistance to spin bowlers. "I get a lot of drift here", Perera said.
Asked about South Africa's preparation to face spin, du Plessis said: "Leading up to a series like this, the quality that you're going to get from some of the spinners, it's not something you can just practice against in the nets". We expected it to be tough coming here.
It was a chastening blow for Faf du Plessis, who admitted that it could well be South Africa's worst loss under his leadership.
Get your defence in order, but when the ball is there to hit, make sure you score.
The skipper opined that a lack of ruthlessness with the ball in the first innings had a domino effect that left the Proteas chasing the game having initially reduced Sri Lanka to 170 for 7.