COLOMBO, Sri Lanka (AP) — Sri Lanka took total control of the second cricket test against South Africa on Saturday, reaching 151-3 in its second innings at stumps on Day 2 to lead by 365 runs after it declined to enforce the follow-on.

South Africa was earlier all out for 124 by tea at Sinhalese Sports Club, giving Sri Lanka a first-innings lead of 214.

Dimuth Karunaratne and Danushka Gunathilaka then added 91 runs for the first wicket of Sri Lanka's second innings.

Keshav Maharaj, who took 9-129 in Sri Lanka's first-innings 338, struck in successive overs to remove Gunathilaka (61) and Dhananjaya de Silva (0).

Sri Lanka also lost Kusal Mendis when he was run out for 18.

Karunaratne was unbeaten on 59 at stumps with Angelo Mathews on 12.

Sri Lanka had resumed Saturday on 277-9 and extended its first innings with a record 74-run, last-wicket stand.

South Africa was 19-3 at lunch in its first innings and lost the remaining seven wickets in the afternoon session.

Sri Lanka leads the two-match series 1-0, having won the first test by 278 runs.

South Africa has not lost a series to Sri Lanka since 2006.

Akila Dananjaya, who took his second test five-wicket haul, wasn't sure what target Sri Lanka wanted to set South Africa.

"We haven't thought of a target as such. We will have a chat tomorrow and see," Dananjaya said. "We have put in lot of hard work so far and we need to continue doing this."

Both Sri Lanka openers Karunaratne and Gunathilaka posted half-centuries before Maharaj made the breakthrough when Gunathilaka was caught at deep mid-wicket by Dean Elgar. Gunathilaka hit six fours and two sixes.

In his next over, Maharaj dismissed Dhananjaya de Silva as South Africa successfully reviewed a leg-before-wicket appeal that was initially turned down.

Karunaratne's prolific series continued as he posted his third half-century. He also scored an unbeaten 158 in the first innings of the Galle test and has accumulated 330 runs in the series — more than the entire South African team after three innings.

"It's the toughest series so far," said South Africa coach Ottis Gibson. "We played three days in Galle and two days here. The toughest five days certainly. It's been a lesson and one that we learn moving forward."

Earlier, Sri Lanka proved that there were no demons on the wicket in their first innings as the last-wicket pair of Rangana Herath and Dananjaya extended their stand to 74 runs. Dananjaya was left stranded on 43 not out, his test best score.

Left-arm orthodox spinner Maharaj's 9-129 was the second best haul by a South Africa bowler behind Hugh Tayfield's 9-113 against England in Johannesburg more than 60 years ago.

The tourists lasted little more than two hours — and 34.5 overs — in their first innings as the off-spin duo of Dilruwan Perera (4-40) and Dananjaya (5-52) shared nine wickets between them. Veteran Rangana Herath claimed the remaining wicket.

South Africa captain Faf du Plessis top scored with 48 runs.

Hashim Amla (19) was the first to fall after lunch but not before becoming the third South African to reach 9,000 test runs after Jacques Kallis and Graeme Smith.

Dale Steyn, seeking to become South Africa's outright record wicket-taker, returned 0-60 in the first innings off 17 overs, and 0-11 from four overs in the second innings so far.