Kumar Sangakkara smashed his 49th half-century as Sri Lanka launched a fightback on the fourth day of the first Test against South Africa on Saturday.
The prolific left-hander also shared 96 runs for the unbroken second wicket with Kaushal Silva (37) to take Sri Lanka to 110-1 at stumps.
The hosts need 260 runs with nine wickets in hand to pull off a magical come-from-behind win with three full sessions left in the game.
"In a situation like this where you have 90 overs to bat, a win is not guaranteed but there is a chance," Sri Lankan coach Marvan Atapattu said after the day`s play.
"It`s a challenging total but we`ve got a team which is willing to fight."
Sri Lanka had been forced on the backfoot after they were bowled out for 292 to concede a huge 163-run lead in the first innings.
But a sporting declaration by new South African skipper Hashim Amla at the tea score of 206-6 turned the game on its head.
Although no team has ever scored more than 300 runs in the final innings at Galle, the 36-year-old Sangakkara made a target of 370 look chaseable.
The star batsman hit seven fours and a six in his 58-run knock that came off 89 deliveries.
South Africa began their defence well, with Dale Steyn once again giving his side the early breakthrough by dismissing opener Upul Tharanga for 14.
But Sangakkara stood like a rock at the other end, once despatching a full-toss from Tahir over the mid-wicket fence for a huge six.
He completed his half-century in style, sweeping leg-spinner Imran Tahir through midwicket for a four.
Silva also knocked off some easy runs, smacking part-timer Jean-Paul Duminy for two fours in a row."Look, they are very much in the contest, there`s no doubt about it. But so are we," said South African coach Russell Domingo.
"We are set up for a cracker of a day tomorrow (Sunday). If we take two early wickets, we will be right on top of the game."
Vernon Philander, who was fined 75 percent of his match fees after being accused of ball tampering Friday, bowled six wicketless overs for 13 runs.
Earlier, AB De Villiers hit six boundaries in his breezy 58-ball 51 and also shared 62 runs with Quinton de Kock (36) to set up South African second innings.
The Proteas had made 455-9 declared in their first essay.
To their credit, the Sri Lankan spinners exploited well the dry and dusty track, accounting for all the wickets that fell in the South African second innings.
Off-spinner Dilruwan Perera picked an impressive 4-79 while Rangana Herath took 2-84.
Perera struck early into the second session, claiming the big wicket of Amla, who is leading South Africa for the first time in Test cricket.
Amla (22) mistimed his flick and lobbed the ball to a diving Upul Tharanga for his second cheap dismissal in the game.
Faf du Plessis (37) fell to a turner from Herath that crashed on to his stumps, dislodging the bails.
De Villiers frustrated the spinners with his shot-making until his stumps were shattered by Perera close to the tea break.
De Kock fell on the last ball before the break, lobbing an easy return catch to Perera.
Opener Dean Elgar, who made 103 in the first innings, made 12 while Alviro Petersen (32) was given caught behind off Perera.
South Africa had wrapped up the Sri Lankan innings in the fifth over of the day, with the hosts adding just nine runs to their overnight 283-9.
The second and final Test will be played in Colombo from July 24-28.