Sri Lanka overcame a top order collapse as they rebounded from the ball-tampering row in the second Test against the West Indies to set up a thrilling final day at Gros Islet.
A day after holding up play for two hours having been penalised five runs for allegedly altering the condition of the ball, Sri Lanka slipped from 32 without loss to 48 for four in their second innings.
Paceman Shannon Gabriel was a constant menace and ended the penultimate day with career-best Test figures of 6-57 and his maiden 10-wicket match haul, but the tourists refused to roll over.
Kusal Mendis and Sri Lanka captain Dinesh Chandimal - who, on Sunday, pleaded not guilty to an International Cricket Council charge of attempting to change the condition of the ball - led the recovery with a vital 117-run stand.
Mendis contributed 87 before Niroshan Dickwella continued the revival with an important 62 to usher Sri Lanka to 8-334 and a lead of 287 at stumps as they seek to level the three-match series at 1-1.
Chandimal was charged on the basis of television footage which allegedly shows him applying a substance to the ball during the final session of day two.
"Sri Lanka captain Dinesh Chandimal has pleaded not guilty to breaching Article 2.2.9 of the ICC Code of Conduct and, as such, Javagal Srinath of the Emirates Elite Panel of ICC Match Referees will hold a hearing following the conclusion of the St Lucia Test against the Windies," an ICC statement said.
"The officials laid the charge after television footage from the final session's play on Friday appeared to show the Sri Lanka captain taking sweets out from his left pocket and putting these in his mouth, before applying the artificial substance to the ball which the umpires viewed as an attempt to change its condition.
"Video evidence will be used in the hearing, which will also be attended by the match officials as well as members of the Sri Lanka team management."
West Indies were awarded five penalty runs after umpires Dar and Gould raised concerns about the condition of the ball, prompting a Sri Lankan protest as the tourists took to the field for Saturday's play two hours late.
Sri Lanka cricket also issued a statement backing its players.
"The team management has informed us that Sri Lankan players have not engaged in any wrongdoing during the ongoing Test match played between Sri Lanka and West Indies," it read.
"SLC shall take all necessary steps to defend any player, in the event any unwarranted allegation is brought against a member of the team."
Chandimal scored an unbeaten 119 in his side's first innings after winning the toss and electing to bat.