BRISBANE, AUSTRALIA -- Down a player after star forward Lauren James was ejected, England was facing the prospect of an upset against Nigeria and a round-of-16 exit at the Women's World Cup.
The European champion Lionesses remained calm enough to get through regulation and extra time at 0-0 and won a penalty shootout 4-2 to scrape into the quarterfinals on Monday.
England became the title favorite after the two-time reigning champion U.S. was eliminated on Sunday in a penalty shootout loss to Sweden. No. 2-ranked Germany, Olympic champion Canada and Brazil didn't even reach the knockout stage.
But the Lionesses struggled to create opportunities against Nigeria and, with five minutes remaining in regulation, an upset loomed when James received a red card after a VAR review.
She initially was given a yellow card by referee Melissa Borjas after falling on top of Michelle Alozie and then stepping on the Nigeria defender. The crowd groaned as slow-motion replays on the stadium screens showed the incident, and, after a delay of several minutes, the yellow card was upgraded to red.
British media instantly reacted by comparing it with David Beckham's red card for kicking out at Argentina's Diego Simeone at the 1998 World Cup in France. The red card means James will miss at least the quarterfinal and a potential semifinal.
But after a run of injuries to senior players and the loss of James, England coach Sarina Wiegman praised her team for adapting to every challenge.
"I've never experienced so many problems," Wiegman said. "It's my job to think of things that can happen in a game or a tournament. You try to turn every stone and try to already think of a solution if things happen. Today, we got totally tested on those turned stones."
Wiegman said her 21-year-old star "in a split second lost her emotions."
"Of course she doesn't want to hurt anyone," the coach added. "She's the sweetest person I know."
The Lionesses immediately had to change formation in the 10-on-11 scenario, bringing on Chloe Kelly to play a solo role up front. She kicked the final penalty to clinch the shootout win.
Alozie was clear eight minutes into stoppage time but skewed her left-foot shot from seven yards wide of the post.
Veteran forward Asisat Oshoala forced a save from England goalkeeper Mary Earps deep in extra time.
After narrowly escaping with a win, England will meet Colombia or Jamaica in Sydney next Saturday in the quarterfinals.
"It's amazing. Anything that's thrown at us. We've shown what we're capable of," Kelly said. "We dig deep as a group and we believe in our ability. This team is special ... there's more to come."
Nigeria coach Randy Waldrum praised his team for going wire-to-wire with one of the best teams in the world.
"I'm so proud of them, to come in and play like we did tonight," Waldrum said. "The players right now obviously are in tears. They believed we could win and they expected to continue playing on.
"We gave everything. I certainly hope that people back in Nigeria appreciate the job that they've done while they're here and I would hope that they're happy, not upset that we lost."
Uchenna Kanu threatened with two headers in the second half, one just after the break that went just over the crossbar and another in the 72nd when she leaped to meet a corner kick but nudged it back past the near post.
Rachel Daly's powerful header as she ran into the box to meet a corner in the 75th was blocked by Chiamaka Nnadozie, who made two tremendous saves in the first half.
Nigeria had eight shots in the first half and created the better chances, including Ashleigh Plumptre's running left-foot strike into the crossbar in the 17th minute and her right-foot shot moments later that forced a diving save from England keeper Mary Earps.
A half-hour in, England was awarded a penalty when Daly appeared to be bumped to the ground in the area by blue-haired defender Rasheedat Ajibade, but it was overturned on VAR and brought a booming roar from the 49,461-strong crowd.
Oshoala went on as a substitute as the hour approached, with Nigeria aiming to reproduce the surge in attack her entry generated in the upset of Australia in the group stage. It generated more intensity but no goals.
Nigeria troubled the higher-ranked teams throughout the tournament after opening with a 0-0 draw against Olympic champion Canada and the win over Australia.
England advanced atop Group D, after struggling to a 1-0 opener against Haiti and edging Denmark by the same margin, the Lionesses unloaded with James scoring twice in a 6-1 win over China in a pool finale that drew a TV audience exceeding 53 million in China.
Losing James to suspenion will be another test of England's depth.
Beth Mead, who won the Golden Boot at the 2022 Euros, injured an ACL when playing for Arsenal in December. Leah Williamson, also playing for Arsenal, tore an ACL in April, and Fran Kirby is also missing from the Women's World Cup roster because of an injured knee.