The victory was set up by spinners Ajantha Mendis and Sachithra Senanayake, who shared seven wickets to restrict the reigning world champions to 264-9 in the day-night match in Fatullah.
But Sri Lanka lost wickets at regular intervals and were reduced to 216-7 in the 44th over when Thisara Perera helped Sangakkara add 42 crucial runs for the eighth wicket.
Left-handed Sangakkara, who hit 12 boundaries and a six in his 18th one-day century, fell in the penultimate over when just seven runs were needed for victory.
But Mendis and Perera saw Sri Lanka through with four deliveries to spare in a nail-biting finish, giving their team a second win after they beat Pakistan in the tournament opener.
India, who won against Bangladesh, must defeat arch-rivals Pakistan in Dhaka on Sunday to stay in contention for a place in the final.
Sangakkara, a 36-year-old veteran of 366 one-day matches, said India did well to make the game a close affair.
"The dew on the ground made it a lot easier