Mohammed Shami took a dramatic hat-trick to finally clinch a thrilling 11-run win over Afghanistan after the minnows threatened one of the biggest shocks in World Cup history in Southampton on Saturday.
Afghanistan, appearing at only their second World Cup, lost the toss but restricted India to 224 for eight in their 50 overs, giving themselves a genuine chance for a huge upset.
They were well set at 106-2 in the 29th over, even though the run-rate was starting to edge up, but two wickets in one over from paceman Jasprit Bumrah removed Rahmat Shah and Hashmatullah Shahidi.
Mohammad Nabi and Najibullah Zadran batted sensibly to keep their side in the hunt, but when Zadran was caught by Yuzvendra Chahal off Hardik Pandya, Afghanistan were 166-6 in the 42nd over.
Nabi was still there in the final over, with 16 required and drilled Shami's first ball down the ground for four.
India vs Afghanistan Highlights
With an incredible triumph within touching distance, Nabi was caught by Pandya at long on two balls later.
Shami then clean-bowled Aftab Alam and Mujeeb Ur Rahman to seal a nerve-jangling win with a hat-trick.
"This win is right up there. We thought 250 was par and 270 would have been an outstanding effort. A team like Afghanistan doesn't let you play how you want to play," India captain Virat Kohli said.
"At the halfway mark we had some doubts in our mind but everyone had belief in the changing room."
Frustrated Afghanistan skipper Gulbadin Naib added: "We bowled really well. We did well in batting, but credit to Bumrah for how he bowled in the last two or three overs.
"If you chase 250 then middle order batsmen should go longer and take responsibility."
Earlier, an increasingly fraught India were furious when the umpire turned down a huge lbw shout at the start of the 29th over from Bumrah, who rapped Shah on the pads -- Kohli's side had no reviews left.
Just three balls later Shah, on 36, top-edged a hook and Chahal took a fine low catch running in from fine leg, sending the massed ranks of flag-waving Indian supporters wild.
With his final ball of the over Bumrah turned the game sharply back in India's direction when Shahidi could only offer up a simple caught-and-bowled chance and he departed for 21.
Bumrah -- the world's top-ranked one-day international bowler -- finished with figures of 2 for 39 from his 10 overs, bowling superbly at the death.
Shami finished with figures of 4-40.
"When the captain has so much trust in you, it gives you a lot of confidence to express yourself. That helps me keep a clear head," said man-of-the-match Bumrah.
Afghanistan have been the whipping boys of the tournament in England and Wales, often looking out of their depth against the more established teams.
Saturday's match was only the third one-day international between the two teams and defeat for India would have been a major embarrassment despite last year's tie in the Asia Cup
India were on the back foot right at the start of the match when in-form opener Rohit Sharma, who has scored two hundreds so far in the tournament, was dismissed for just one by off-spinner Mujeeb Ur Rahman.
The rest of India's powerful top order all got established, with Kohli making 67 from 63 balls, but none went on to play a decisive innings for the two-time champions.
Off-spinner Mujeeb was particularly impressive, conceding just 26 runs in his 10 overs, while leg-spinner Rashid Khan bounced back from the most expensive spell in World Cup history against England to take 1-38.
Kohli, who scored half-centuries against Australia and Pakistan, reached his third consecutive fifty of the tournament off 48 balls, with four fours, but was caught by Shah off the bowling of Nabi.
Kedar Jadhav reached his fifty off 66 balls, giving the scorecard a look of respectability and the total ultimately proved just too much for Afghanistan.