South Africa's spin frailties were laid bare once again as the tourists collapsed for 124 to concede a first innings lead of 214 runs at Colombo's Sinhalese Sports Club Ground.
Sri Lanka, who made 338 in the first innings, were 151-3 at stumps after deciding not to impose follow-on against the tourists who now stare at the possibility of a second successive test defeat inside three days.
Dimuth Karunaratne was batting on 59 at stumps, his fourth successive 50-plus knock in the series, with Angelo Mathews on 12 at the other end.
For South Africa, left arm-spinner Maharaj took his match-haul to 11 wickets but his team were in dire straits.
Earlier resuming the day on 277 for nine, Akila Dananjaya and Rangana Herath frustrated South Africa with a dogged 74-run stand for the final wicket before Maharaj struck when the latter was caught behind for 35. Dananjaya remained unbeaten on 43.
Maharaj's 9-129 is the second best by a South African in tests, behind only Hugh Tayfield's 9-113 against England in 1957, but his success brought little cheer to a side battling their own spin vulnerabilities.
Herath and Dananjaya (5-42) returned from the innings break to harm South Africa with the new ball, reducing the leaden-footed tourists to 15 for three.
Dilruwan Perera (4-40) then joined the rout as South Africa lost all 10 wickets to the Sri Lankan spinners.
Faf du Plessis (48) and Quinton de Kock (32) counter-attacked but it was not enough as the tourists once again failed to reach the 150-mark in the series.
First Published: July 21, 2018, 5:49 PM IST