William Accambray's superbly taken winner on the final buzzer sent Beijing bronze medallists Spain's players tumbling to the floor in despair, the Frenchman top scoring despite not having previously set foot on court at the London Games.
World champions France, greeted in the Basketball Arena by an impromptu rendition of "La Marseillaise" from their fans, crept past Spain 23-22 while Hungary goalkeeper Nandor Fazekas saved a last-ditch penalty to set up extra-time against Iceland.
Hungary, seeking a first Olympic men's handball medal after four fourth-placed finishes in seven previous Games appearances, prevailed 34-33 and will play three-times runners-up Sweden who beat European champions Denmark 24-22 in a see-saw clash.
France will next face twice Olympic champions Croatia, who maintained their unbeaten run at the London Games by defeating outsiders Tunisia 25-23 in another fast and furious knockout stage tussle that left crowds breathless once again.
Spain goalkeeper Arpad Sterbik Capar had been in great form in the first half against France as the reigning champions went 11 minutes without a goal, but he could do nothing about Accambray's gravity-defying strike.
Sterbik Capar kept out French talisman Nikola Karabatic's last-second shot but to his horror the rebound flew straight to Accambray, who in the blink of an eye leapt forward, grabbed the ball, switched it to his right hand, and finally let rip.
"The ball did not want to let go of me. It was too sticky," he told Reuters, joking the ball was covered in too much of the glue-like resin that is used to help players keep hold of it.
Coach Claude Onesta only informed Accambray he would make his tournament debut on Tuesday but said he knew the 24-year-old would handle the pressure.
"I knew that he could bring his freshness and explosiveness to the team," said a relieved Onesta, whose team looked below par throughout and had impatient France fans cursing for most of the bleak first half.
In contrast, Hungary's team burst into life like their upbeat followers, though they still required a huge slice of luck and then frenzied teamwork to extend the game.
Fazekas repelled a Snorri Steinn Gudjonsson penalty with seconds left of normal time and then Mate Lekai, threaded into position by a series of hurried passes, levelled the scores at 27-27 with the referee all set to blow the whistle.
The power and ferocious left-arm throws of Laszlo Nagy, who stands at 2.09 metres and top scored with nine strikes, proved the key to unlocking Iceland's robust defence in extra-time as he flung in five of his team's seven goals.
"Luck was with us, we have to realise that. But we have a good goalkeeper capable of stopping penalties which he did," said the 31-year-old Barcelona captain.
"I think the team was complete today, every player brought a lot to the victory. Now it's time to rest," he said, looking exhausted.
Iceland's outgoing coach Gudmundur Gudmundsson, hoping to lead the tiny volcanic nation to another Olympic medal after he helped secure the country's first silver since the 1956 Games four years ago in Beijing, refused to blame Gudjonsson.
"We're all upset. You have to look at the whole game. This is the way sport is, you do or die," he said.
"We dearly wanted to repeat the silver medal of four years ago. I'll now let some other people talk about leading the team onwards," he said, smiling humbly after eight years in charge.
Sweden edged a lacklustre Denmark largely thanks to the heroics of goalkeeper Johan Sjostrand, barged playfully into his net on the final whistle by his grateful teammates as world player of the year Mikkel Hansen stood shellshocked.
"We play together," said Sjostrand, refusing to accept any praise.
The fervent action had showed no sign of coming to a halt all day and although Croatia were heavy favourites against Tunisia the Africans held a one-point halftime lead.
Both teams let out blood-curling screams of joy and pounded court-side billboards in anger all game but the Europeans, hoping to become the first male side to win three Olympic titles, turned up the heat in the second half.