Southampton: Mohammed Shami (4/40) grabbed a magical hat-trick as India scripted a 11-run last-over win over Afghanistan in a thrilling World Cup clash here on Saturday.
Chasing 225 for victory, Afghanistan needed 16 runs in six balls riding Mohammad Nabi's valiant 52 off 55 balls and including four boundaries and a sixer.
Nabi smacked Shami for a four to bring the equation down to 12 off 5, and then refused a single to keep the strike.
But in the next three balls, Shami had Nabi caught by Hardik Pandya at long on and then castled Aftab Alam and Mujeeb ur Rahman in successive deliveries to grab a hat-trick and hand India their fourth victory in five matches.
Shami became India's only second bowler to bag a hat-trick in a World Cup since Chetan Sharma in the 1987 edition.
Pace ace Jasprit Bumrah (2/39), wristspinner Yuzvendra Chahal (2/36) and all-rounder Pandya (2/51) all grabbed two wickets to help Virat Kohli and Co. escape a scare they never thought would come their way.
Afghanistan spinners had restricted the famed Indian batsmen to 224/8 after Kohli chose to bat first on a sluggish wicket.
Chasing the modest target, Afghanistan lost Hazratullah Zazai (10) early, with Shami getting the ball to go through the gate and crash onto the stumps.
India lost a review early on when a Shami delivery struck Zazai on the pads and umpire Aleem Dar turned down loud appeals. Kohli decided to go for a review as replays showed the ball pitching outside line.
Skipper Gulbadin Naib (27) and Rahmat Shah (36) then shared a 44-run second wicket stand before Pandya had the former holed out to Vijay Shankar at deep midwicket.
There was drama in the 29th over when Bumrah hit Shah's pads and was convinced he has got his man, but the umpire was not convinced, leaving Kohli furious as India did not have any reviews left.
But as things panned out, India's agony was shortlived as the pacer removed both Shah and Hashmatullah Shahidi (21; 45b; 2x4) in the same over.
While Shah holed out to Chahal who took a low catch running in from fine leg, Shahidi was done by a short-of-a-length ball, angled into the batsman as he failed to negotiate it and the ball popped up off his outside of the bat for Bumrah to take a return catch.
From 106/2 after 28 overs with 119 needed from the remaining 22 overs, the Afghans suddenly found themselves in a spot of bother with the loss of their two set batsmen.
Nabi and Najibullah Zadran (21) tried to still keep their hopes alive but once the latter was gone, and Chahal removed Rashid Khan (14), it was all down to Nabi who, in the end, failed.
Earlier, Afghanistan tweakers spun a web around Indian batsmen to restrict them to 224/8 in 50 overs despite half centuries from Kohli and Kedar Jadhav.
This is India's lowest first innings total batting all 50 overs since 2010.
Kohli struck his third consecutive fifty with a classy 67 off 63 balls, his innings laced with five fours, while Jadhav scored 52 off 68 deliveries (3x4, 1x6).
But a spirited Afghanistan, smarting from their heavy defeat to England in the last game, rode Nabi's 2/33 and wickets each for Rahman (1/26), Rashid Khan (1/38) and Rahmat Shah (1/22) to keep the run-flow in check throughout the innings.
Skipper Naib (2/51) took two wickets in the last over, removing Jadhav and Shami (1) to cap off a brilliant bowling display by the team which still finds itself at the foot of the points table, without a win, and battling off-field issues and in-fighting.
M.S. Dhoni laboured to 28 off 52 balls (3x4) bringing back memories of the days when he was questioned for his slow pace in the twilight of his career.
Dhoni was stumped in the end off Rashid, as he tried to up the ante by dancing down the track. This was only the second time he got out stumped, and the first time since 2011.
There was an injury scare to star player Rashid who hurt his left leg while fielding at long on in the 50th over off Naib. Rashid tried to stop a boundary but picked up an injury, and was later seen hobbling off the pitch.
India lost their openers, Rohit Sharma (1) and K.L. Rahul (30) early with Kohli the only player who looked good on the day. Jadhav tried hard to get going in the end, and his fifty was well paced but Dhoni failed to rotate the strike enough and got stuck on a two-paced wicket.
Shankar (29) got a start batting at No. 4 but failed to cash in while fellow allrounder Pandya (7) had a bad day with the bat.
Brief scores: India: 224/8 (Virat Kohli 67, Kedar Jadhav 52; Mohammad Nabi 2/33, Gulbadin Naib 2/51); Afghanistan: 213 all out in 49.5 overs (Mohammad Nabi 52; Mohammed Shami 4/40)