Australia secured the bonus-point they needed with a 34-14 win on Sunday to maintain their slimmest of slim chances of qualifying for the quarter-finals. But the men in green and gold had it far from their own way at a rowdy Stade Geoffrey-Guichard.
Roared on by a wall of noise, Portugal started at a canter. After falling behind early to a Ben Donaldson penalty, Os Lobos produced a thrilling spell of ball-in-hand rugby, ending with centre Pedro Bettencourt crashing over in the corner.
Behind 7-3 after 13 minutes Australia had to dig deep. Helped by a Bettencourt yellow card just two minutes after his try heroics, the Wallabies did sparkle briefly. Three tries in seven minutes - the best a fine flowing team effort finished off by prop Angus Bell - settled the nerves. And when flanker Fraser McReight secured the bonus point soon after half-time it looked like the Wallabies would pull away from the team ranked 16th in the world.
But buoyed by two yellow cards in three minutes for the Wallabies, Portugal refused to crumble. A second Portugal try with nine minutes left on the clock had Australian hearts racing before winger Marika Koroibete finally cooled thoughts of a historic upset. The Wallabies now head into the final weekend of Pool play needing a huge favour from their vanquished opponents. If Portugal can beat Fiji on 8 October and deny the Pacific Islanders a losing bonus point, Australia will limp into the quarter-finals.
Head coach Eddie Jones said his side would prepare this week as it they had qualified for the knock-out stages even if Fiji could end their quarter-final hopes.
"We're still alive," said Jones. "That was the aim of the day. For a young team down to 13 men we showed plenty of courage and fought hard. We've done that all season, sometimes the results haven't been in our favour...well, most of the time.
"It's a real credit to them. You look at the experience of our players out there, we're averaging less than 20 caps."
On the plans for the next week, Jones added: "I've never experienced this before so I really don't know.
"We're anticipating we'll be in the quarter-finals so we have plans to have three days off and then three days training. We'll see on Sunday night. Portugall played with plenty of spirit tonight so you never know."
Australia's number eight Rob Valetini, the Mastercard Player of the Match, hailed his side's display given they knew it could be - and might still be - their final match of this year's tournament.
"It was good. I thought the boys dug deep, knowing it could be our last game," said Valetini. "The boys made it easy for me. Credit it to Portugal, they are a very solid team.
"I know they are going to be a powerhouse in a couple of years."
Portugal captain Tomas Appleton said he was proud of his team's efforts against the two-time world champions, but admitted their performance could have been better.
"We're really proud but we lost, so not happy to be honest. We still have one more shot next week to show what we want - and that is to win - but I'm disappointed," said the centre.
"We took a lot of line breaks from first-phase and after that, if we are always playing on the back foot, it's really hard to compensate when we are playing at this level."
But Appleton heaped praise on the fans who played their part in the incredible atmosphere in the stadium.
He added: "The crowd is simply amazing. We have so many fans coming from Portugal, a lot of fans here in France too - this is what I am most proud of. They are simply amazing."