Fiji reach Rugby World Cup quarter-finals despite historic first win for Portugal
The Pacific Islanders needed a point to progress and knock two-time champions Australia out in the group phase for the first time in World Cup history.
They managed that courtesy of a bonus point awarded for losing by less than eight points, setting up a last-eight clash with England.
Rodrigo Marta scored a try for Portugal two minutes from time and Samuel Marques converted it to earn his side an emotional win.
Portugal, who played without fear and great attacking intent, also claimed tries through Raffaele Storti and Francisco Fernandes as Samuel Marques kicked nine points from the tee.
Fiji and Australia finished Pool C on 11 points, but Eddie Jones's side are out after losing to the Fijians.
Wales advance as group winners and will take on Argentina in the quarter-finals.
"We were a bit tight in the context of the game. Created lots of opportunities but we just didn't throw the ball out to our outside backs. So congratulations to Portugal, they can enjoy tonight," Fiji coach Simon Raiwalui said.
Read more Rugby World Cup 2023: Guide to the quarter-final fixtures
His Portugal counterpart Patrice Lagisquet, who took part in two World Cups with France in 1987 and 1991, was amazed by his players as his four-year tenure ended on a high.
"They still surprise me after four years," he said. "It's incredible, unbelievable, they always find the resources."
Fiji, who scored tries through Levani Botia and Mesake Doge and relied on the boot of Frank Lomani, were in deep trouble when they trailed 17-10 in the second half.
Their superior bench made the difference, however, and Fiji regained the lead with a converted try and a penalty between the 68th and 74th minutes, only for Portugal to produce a late twist.
Both teams played