Portugal secured a historic first Rugby World Cup victory with a last-gasp 24-23 win over Fiji, but the Pacific Islanders nonetheless advanced to a quarter-final showdown with England on Sunday.
Fiji looked to have wrapped up the win with two late Frank Lomani penalties, but there was drama in Toulouse as Rodrigo Marta crossed for a try, converted at the death by Samuel Marques.
Fiji needed one point from the final pool game and they got that for finishing within seven points of Portugal.
The result also ensured Australia failed to qualify for the knockout phase for the first time in history.
Fiji coach Simon Raiwalui said there would be a reset before taking on England in Marseille.
"England are a very good tournament team and we're expecting a tough game," said Raiwalui, who added he was "disappointed not to get the win."
"We dropped too much ball. We were a bit tight in the context of the game."
Captain Waisea Nayacavelu said the focus would immediately switch to England.
"We have to look at our mistakes, do our fine-tuning, regroup and refocus again," he added.
Portugal flanker Nicolas Martins called his team's win "incredible."
"It's historic, I'm so happy. I think it's the best moment of my life," he said.
Rodrigo Marta's late try stuns Fiji. REUTERS