England will play India in the Women's World Twenty20 semi-finals after a narrow defeat in their final Group A game against West Indies in St Lucia.
After losing six wickets in the first 10 overs, England posted 115-8 thanks to an excellent partnership between Anya Shrubsole and Sophia Dunkley.
Shrubsole took two wickets in her first over, but Deandra Dottin and Shemaine Campbelle steadied the hosts.
The defending champions won with three balls to spare and face Australia next.
Both semi-finals will take place on Thursday, with the West Indies match starting at 20:00 GMT and England's beginning about four hours later.
England were put in to bat by the hosts and were quickly in trouble when Danni Wyatt was caught behind off Shakera Selman in the first over.
They stuttered to 50-6 off 10 overs, but after Britney Cooper's brilliant run-out dismissed Lauren Winfield for a duck, Shrubsole and Dunkley moved England towards a competitive total with a seventh-wicket stand of 58.
Both batters hit a six apiece, with Shrubsole falling to the final ball of the innings when Dottin pulled off an outstanding catch diving to her right.
Shrubsole's excellent form continued when she took the ball for the second over of the West Indies reply, bowling Hayley Matthews with her first delivery and Stafanie Taylor with her fourth.
Left-arm spinner Kirstie Gordon tied down and then dismissed Dottin, but Campbelle picked up the scoring rate to take West Indies near to victory, and was missed by Dunkley off a steepling chance in the penultimate over.
It was a frantic finish at the Darren Sammy Stadium, with substitute Fran Wilson allowing a catching chance to go through her hands and then for four, and keeper Amy Jones also dropping a skier - although in the aftermath Cooper was run out by an alert Winfield.
Shrubsole stepped up for the final over with five needed by the West Indies, but after dismissing Campbelle for 45, she saw her next delivery sent to the point boundary by Kycia Knight to give the hosts victory with three balls to spare.
In the other Group A match, South Africa beat Bangladesh by 30 runs as they finished third and bottom respectively.
South Africa made 109-9 before their opponents could only reach 79-5 in their 20 overs.
England captain Heather Knight on BBC Test Match Special: "What a game of cricket, what a great atmosphere - I couldn't be more proud of the fight they showed. A little bit more composure maybe needed to get over the line, but what a game.
"Ideally, you want a player from the top five to bat for most of the innings, and with the ball I think the spinners went slightly over their lengths but in general our bowling's been brilliant.
"Sophia Dunkley hits in weird areas, it's difficult to set fields to her, and she and Anya kept us in the game. Australia and India both look very strong, it looks like it's going to be a great couple of semi-finals.
"Dani Hazell was a bit unlucky as a few of the balls just went over fielders' heads - we'll have to assess what's going to be our strongest XI against India. I've got a bit of a hoarse throat trying to get fielders' attention, but what an atmosphere to play in."
Ex-England captain Charlotte Edwards on TMS: "West Indies look like they can win from anywhere - my money was definitely on England with five overs to bowl. What an incredible game to play in front of a crowd like this - it's what the tournament needed.
"I think the noise affected England as three or four catches went up [and were dropped], but hopefully they'll react better in a semi-final."