India were eyeing a series-leveling win in the second Test by reducing Sri Lanka to 72 for two after setting the hosts a daunting victory target of 413, riding on Ajinkya Rahane's sparkling century.
The 27-year-old Rahane (126) notched up his fourth Test century as India declared their second innings at 325 for eight and then snapped up early wickets to leave the islanders in a shaky position at close on an engrossing fourth day.
India will now look to take the remaining eight wickets on a tricky fifth day track to level the three-match series 1-1 and spoil the party for retiring legend Kumar Sangakkara in his farewell Test match.
Sangakkara, 37, did not have a fairytale ending to his final innings after the one-down batsman departed for just 18 runs. He was scalped for the fourth time in this series by Ravichandran Ashwin (2-27) as the home crowd gave an emotional farewell to the left-handed batsman.
After coming on to the ground amid a standing ovation and guard of honour by the visiting Indian team, Sangakkara was done in by an Ashwin turner to be caught at gully by Murali Vijay. The visiting players, including captain Virat Kohli, then shook hands with the departing Sangakkara as his family
looked on from the stands.
Dimuth Karunaratne (25 not out) and skipper Angelo Mathews (23 not out) then stood their ground for an unbeaten 39-run stand to fight on.
The Lankans will look to score the remaining 341 runs for a series clinching victory though that will a tough task. With two wickets already down, they will try to bat out for a draw on a P Sara oval track, which is expected to deteriorate and assist the spinners.
The highlight of the day was Rahane's knock and his 140-run second wicket partnership with Murali Vijay (82), which put India in a position to take a mammoth overall lead. Rohit Sharma chipped in with a useful 34 before India declared the second innings.
Dhamikka Prasad and Tharindu Kaushal picked up four wickets apiece but failed to stop the flow of runs.
No team has ever scored 413 in the last innings of a Test match on Sri Lankan soil. The highest successful run chase has been achieved by Pakistan only a few months back, when they scored 382 for three against the Lankans in Pallekele.
The highest fourth innings target successfully chased by the hosts has been 352 against South Africa in Colombo in 2006.