South Africa lost the wicket of opener Alviro Petersen for a duck as they chased 369 runs for victory in the second test against Sri Lanka on Sunday (local time).
Petersen was caught at silly point by Kithuruwan Vithanage as he prodded forward to a length ball from Rangana Herath that turned appreciably to take the edge of his bat.
On a pitch that was assisting the spinners, South Africa were spared further damage when bad light ended play with 21 overs still remaining to be bowled for the day.
Dean Elgar was on 13 and wicketkeeper-batsman Quinton de Kock, promoted up the order, on 21, as South Africa ended the day on 38 for one wicket.
South Africa, who lead the two-test series 1-0, require a further 331 runs to win on the final day with nine wickets in hand.
"Sri Lanka has played most of the cricket in this test match, more credit to them but we are still in the slot," South Africa batsman AB de Villiers told reporters.
"We have the batters in the whole team and we are not going to give it up. We rate ourselves very high and we like to back ourselves to win and finish on a high.
"By tea time if South Africa has wickets in hand the possibility would always be there, said De Villiers.
"You've got to find a balance of keeping it positive and keeping the ball along the ground," he added.
Kumar Sangakkara said the hosts' approach was to win at all costs.
"The South Africans have played very well both in the ODI series and in the first Test," he said.
"We were bit poor in Galle and we need to be good for tomorrow and push for a win. Our chances are pretty good. It's a tough wicket for the lefties with Rangana (Herath) bowling on to the rough.
"If we can keep the pressure with Dilruwan (Perera) bowling from the other end that would be good," he said.
Earlier, Sri Lanka captain Angelo Mathews completed his second half-century of the match and went past 1,000 runs for the calendar year before declaring at the fall of the eighth wicket on 229.
The right-hander followed his first-innings 63 with a similar knock to remain unbeaten on 63 with two sixes and two fours.
Sri Lanka lost two wickets in the final session with Imran Tahir bowling Dilruwan Perera for seven and Morkel claiming his fourth wicket of the innings by having Herath caught by De Villiers for four.
Sangakkara and Mathews led Sri Lanka's hunt for quick runs with a fourth-wicket partnership of 81.
Sangakkara registered his 50th test half century with an aggressive 72 off 90 balls, including eight fours, before he was dismissed edging Morkel to de Kock.
Morkel picked up his 200th test wicket when Kithuruwan Vithanage (seven) was caught splendidly by Faf du Plessis at backward point off a top edge.
Niroshan Dickwella (16) fell to Dale Steyn when he top edged a pull to lob up an easy catch for de Villiers at square leg.
Wicketkeeper Dickwella was earlier fined 10 percent of his match fee and officially reprimanded by the match referee for claiming a catch on the bounce off De Villiers and celebrating it by throwing the ball in the air on Saturday.
Sri Lanka lost three wickets in the morning session, including that of first-innings centurion Mahela Jayawardene for a duck.
Jayawardene was given out caught off his glove when he attempted to reverse sweep leg-spinner Tahir.
He immediately referred the decision but as there was no conclusive evidence to overturn the umpire's call, Jayawardene had to go and he trudged off unhappily, certain that the ball had hit his arm guard.
Resuming on 11-0, Sri Lanka made clear their attacking intentions when play began with Upul Tharanga straight driving the first ball of the day from Vernon Philander for four.
Tharanga lived dangerously outside his off stump and eventually edged a delivery from Steyn to de Kock to be dismissed for 30 following an opening stand of 38 with Kaushal Silva who fell for 26 when he scooped Morkel to Philander at point.
Should bouncers be banned from cricket?