Captained by superstar skippers Kylian Mbappe and Cristiano Ronaldo, the two European heavyweights put on an insipid first half for their global audience, but a slow-burn encounter briefly burst to life soon after the break.
Mike Maignan made two sharp saves in quick succession, before Randal Kolo Muani was denied an opener by the brilliance of Ruben Dias at the other end; Ousmane Dembele and Mbappe also threatened to score in the closing stages.
However, with both sides tiring, the game was inevitably bound for extra time and spot-kicks: it was France who prevailed after a superb series of penalties was ended by Joao Felix striking the post - every French player scored from 12 yards when it really mattered.
Les Bleus are yet to score from open play at these Euros but still live to fight another day, succeeding in their attempt to reach the semi-finals for a fourth time in the last five major tournaments; meanwhile, Ronaldo's international retirement could be impending.
Hernandez puts France through to the final four
After 120 goalless minutes in Hamburg, Theo Hernandez scores France's winner in a high-stakes penalty shootout, putting his nation through to the Euro 2024 semi-finals with a confident strike.
Joao Felix was the only man to err from 12 yards, meaning subsequent conversions from Bradley Barcola and Hernandez would send Portugal crashing out.
Led by old stagers Ronaldo and Pepe, the Selecao succumb and exit the stage before the Euros' final act, but they had their chances to win during the first 90 minutes and then could not win a second successive shootout at the tournament.
Kolo Muani's missed shot at redemption
Not for the first time in a major match, Randal Kolo Muani came up just short when it really mattered, as the Paris Saint-Germain striker missed a golden chance to decide the game in France's favour.
Delaying for a split-second allowed Ruben Dias to lunge in and spectacularly save the day, but - like in the 2022 World Cup final - Kolo Muani could have made himself a national hero.
Ultimately, it did not cost his side progress to the semi-finals, for which he will be eternally grateful to his clinical teammates, who went on to spare his blushes in the penalty shootout.
Ronaldo's final act for Portugal? Plus a lack of French bite
France have failed to score a single goal from open play in their last six matches - including an extra 30 minutes today - with their three strikes at Euro 2024 so far coming from two own goals and a penalty.
Didier Deschamps made two alterations from an edgy 1-0 win over Belgium in the last 16 - dropping Adrien Rabiot for Eduardo Camavinga; Kolo Muani coming into the starting XI at Marcus Thuram's expense - but his team still lacked fluency.
Meanwhile, Portugal captain Cristiano Ronaldo has now failed to score in any of his last nine appearances at either the World Cup or the Euros - surely that heralds the end of his long reign as the Selecao's undisputed starting striker?
What next?
France will now meet Spain in Munich next Tuesday, for the right to reach the Euro 2024 final five days later.
Portugal, meanwhile, will have to consider the status of some senior players ahead of their upcoming UEFA Nations League campaign, which kicks off in September.