Playing his 134th and final test, Sangakkara made 32 as he and Kaushal Silva (51) added 74 runs to help Sri Lanka overcome the early loss of opener Dimuth Karunaratne.
Lahiru Thirimanne was batting on 28 at the close with skipper Angelo Mathews on 19 at the other end with the hosts, who lead the three-match series 1-0, still trailing by 253 runs in the evenly poised test.
Sangakkara walked out to a guard-of-honour by the Indian team after Umesh Yadav had dismissed Karunaratne with his first delivery at the P Sara Oval.
The first ball Sangakkara faced was a vicious inswinging yorker from Yadav which the left-hander barely managed to dig out.
He also got a reprieve on 24 when Ajinkya Rahane failed to take a catch at slip after Sangakkara had attempted a cut shot off Ravichandran Ashwin.
The Indians soon combined again to dismiss Sangakkara, who got a standing ovation on his way back to the pavilion while his opponents clapped.
Silva was caught behind off Stuart Binny when on 14 but it turned out to be a no-ball and the opener went to notch up his ninth test fifty before sweeping leg-spinner Amit Mishra to Ashwin at short fine leg.
Earlier, Wriddhiman Saha (56) capitalised on a charmed life to hit his second successive test fifty as India inched close to the 400-mark before being all out soon after lunch.
Resuming on 319 for six, the visitors lost Ashwin early but Saha added 46 runs with Mishra (24) to frustrate the hosts.
Sri Lanka bowled without luck, illustrated best in the second over of the day when Dhammika Prasad’s delivery brushed Saha’s off-stump but could not dislodge the bails.
Left-arm spinner Rangana Herath claimed the last two Indian wickets to finish with figures of 4-81.