Sri Lanka 287 (Karunaratne 158*, Rabada 4-50, Shamsi 3-91) & 190 (Karunaratne 60, Maharaj 4-58, Rabada 3-44) beat South Africa 126 (du Plessis 49, Dilruwan 4-46, Lakmal 3-21) & 73 (Philander 22, Dilruwan 6-32, Herath 3-38) by 278 runs
Sri Lanka's spinners shot South Africa out for 73, their lowest total since readmission and lowest in Sri Lanka, just a day after their previous lowest in the country - 126 - to condemn them to one of their worst defeats in the subcontinent and leave them with no chance of a series win.
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.
Herath surpassed Shaun Pollock and Dale Steyn in this match. Steyn has been chasing Pollock's record of 421 wickets to become South Africa's leading Test wicket-taker and drew level in this match. That will serve as scant consolation for South Africa, whose line-up has serious questions to answer about their shot selection and temperament.
South Africa have never faced fewer overs in Asia than they did in this innings. Only three of their batsmen got into double figures and only one, No. 7 Vernon Philander, scored more than 20. They lost wickets at intervals of between five and nine minutes between lunch and tea and lost the game inside eight sessions. Dimuth Karunaratne on his own scored more runs - 218 - than South Africa over both innings - 199.
Despite forcing a collapse that saw Sri Lanka lose 6 for 73 on the third morning, South Africa were facing a mammoth task after conceding a first-innings deficit of 161 runs. They were set 352 to win, which required them to pull off the joint third-highest successful chase on the island against an attack they have been unable to decipher.
Some tried to attack, like Dean Elgar, who ran down the track in an attempt to loft Dilruwan down the ground and was stumped, others to defend, like Hashim Amla, who was drawn forward and popped up a catch to leg gully, and Temba Bavuma, who inside-edged to leg gully to a Dilruwan delivery that ripped in sharply. Elgar's 50th Test only yielded 12 runs, Amla's second-innings duck was the 12th of his career and Bavuma has yet to show what he can do after being promoted to No.4.
Faf du Plessis was the only one of the top six who showed some staying power in the first innings but he became Herath's first second-innings' victim when he offered a catch to slip. Du Plessis was unable to get to the pitch of the ball, as was Aiden Markram, who jumped out of his crease to a Herath delivery that was dangled outside off, and was stumped. When Quinton de Kock missed his sweep and was given out lbw, South Africa had lost their top six for just 36 runs.
Dilruwan's five-for came when Keshav Maharaj swung and found deep midwicket. He went one better and took his sixth when he set Kagiso Rabada up with one that turned away sharply and followed up with one that went straight on, from around the wicket, to bowl him as he shouldered arms. Dale Steyn handed Herath a return catch and South Africa's misery ended when Lakshan Sandakan, who was only brought on in the 29th over, trapped Tabraiz Shamsi on the back pad.
Though the Galle surface offered turn and bounce and the Sri Lankan spinners were a handful with the new, hard ball, South Africa were also responsible for their own malaise. Their struggles in reading turn and flight, and their impatience, undid them and they will have five days to rethink their strategies ahead of a must-win second Test.
South Africa may even have to address team selection. Philander, for all his resistance with the bat, only bowled 11 overs in the match, and may have to make way for another batsman, Theunis de Bruyn, or a different style of fast bowler, Lungi Ngidi. The only positives for South Africa came from the rest of their attack. After a wicketless first innings, Maharaj took four in the second while Rabada's ability on pitches that offer very little to the quicks was impressive.
Rabada gave South Africa a chance to compete on the third day, first when he fortuitously deflected a ball onto the non-striker's stumps in his follow-through, to run out Roshen Silva, and then with two wickets in three balls, which also brought up 150 in Tests. Rabada is not the quickest to reach the landmark - Sydney Barnes did it in 24 matches - but he is in the top dozen.
For Sri Lanka, there is only cause to celebrate (and perhaps for some of the batsmen to consider how they can emulate Karunaratne). Playing without their captain, Dinesh Chandimal, and coach, Chandika Hathurusingha, who will sit out the series as they await the verdict of their code-of-conduct hearing, Sri Lanka imposed themselves on a team that beat them convincingly just 18 months ago, in South Africa, and won their last series in Sri Lanka. And now, they are only a draw away from a series win.