India were knocked out of the World Twenty20 despite a one-run victory over South Africa in the final Super Eight fixture.
Pakistan's win over Australia earlier in the day left India facing a tough task to claim the second semi-final place from Group Two.
They needed to win and improve their net run-rate above Pakistan's, which in the event meant they had to restrict South Africa to 121 or fewer chasing a target of 153.
Faf du Plessis' 65 off 38 balls ensured that was never likely as South Africa - who were already eliminated - went past 121 in the 17th over.
But South Africa failed to finish off the run chase, they were bowled out for 151 from the penultimate delivery to slump to their third straight defeat in the Super Eight phase.
Suresh Raina (45) and Mahendra Singh Dhoni (23no) had earlier ensured India reached 152-6 after being asked to bat.
Fast bowler Morne Morkel (2-28) and left-arm spinner Robin Peterson (2-25) claimed two wickets apiece to help reduce India to 112-5 after 16 overs but sixth-wicket pair Raina and Dhoni turned things round with a 40-run stand from the final 24 balls.
Hosts Sri Lanka will play Pakistan on Thursday and Group Two winners Australia take on West Indies on Friday in the semi-finals.