Holders France beat Spain with a last-gasp goal for a 23-22 victory as Hungary pipped Iceland with a thrilling 34-33 extra-time win in the men's handball quarter-finals on Wednesday.
Spain's on-song goalkeeper Arpad Sterbik Capar had saved almost everything in the first half but could do nothing about William Accambray's brilliantly-taken winner on the final buzzer.
France endured 11 minutes without scoring in a bleak first half for the reigning champions, but roared on by the crowd they fought back against the 2008 Beijing bronze medallists.
France will face the winners of Croatia, unbeaten so far at these Games and twice Olympic champions, against outsiders Tunisia while Hungary await either European champions Denmark or three-times runners-up Sweden.
Earlier Hungarian goalkeeper Nandor Fazekas saved a Snorri Steinn Gudjonsson penalty with seconds left of normal time and Mate Lekai levelled the scores at 27-27 with two seconds remaining.
The giant Laszlo Nagy top-scored with nine goals to give Hungary a chance of a first men's Olympic handball medal after four fourth-placed finishes in seven previous Games.
Standing at 2.09 metres, Nagy's power and ferocious left-arm throws proved the key to unlocking Iceland's robust defence in extra-time, scoring 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, 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, with Iceland unbeaten in the group stages and chasing a first Olympic gold medal.
"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. "I've had a fantastic time."