With the 26-23 win, four-times bronze medal match losers Hungary set up a last-eight clash with Beijing 2008 runners-up Iceland on Wednesday, the unbeaten Group A winners having signed off with a 41-24 stroll past Britain.
Tunisia joined Hungary in the knockout stages when they beat debutants Argentina in the day's second head-to-head group stage battle for a quarter-final slot, the Africans winning a fiery Group A encounter 25-23.
They will play twice winners Croatia, who kept up their perfect record after defeating Beijing bronze medallists Spain 30-25 in Group B's final game.
The other two quarter-finals on Wednesday will be between holders France and neighbours Spain, then three times silver medallists Sweden v European champions Denmark.
Hungary powered back in the second half thanks to seven goals from Tamas Mocsai to win and spark scenes of wild celebration, Gergely Harsanyi lobbing the ball into the largely pro-Hungary crowd on the final buzzer.
A fed-up Serbia coach Veselin Vukovic had instilled in his players how important the game against Hungary was.
"I told them it was an historic chance to reach the quarter-finals. Now I have nothing to say," he told Reuters.
"Hungary showed they were the better team today but I'm sure that in a normal game we are better."
Counterpart Lajos Mocsai said his players, seen ambling in relaxed fashion around the vast shopping centre close to the Olympic athletes' village on Sunday, were on edge leading into the game and he was delighted with their response.
"We were stressed last night because it was a big game. I'm so proud," he told Reuters through an interpreter, fully aware his team faces a tough task against Iceland.
"We can do even more and we'll do whatever we can."
Iceland coach Gudmundur Gudmundsson was not taking Hungary lightly despite his team's fine form as they continue their pursuit of the tiny volcanic nation's first Olympic gold medal.
"We have a lot of confidence but this is where the competition starts. Anything can happen," he told Reuters following a brilliant group stage where Iceland beat France by a point in a rematch of the Beijing final.
Reigning champions France beat Sweden 29-26 in the last group tussle to take second in Group A and set up their knockout stage clash against Spain.
Denmark disappointed their coach Ulrik Wilbek, who said they were "outmuscled" by a pumped up South Korean side, though they still ran out 26-24 winners and will now play Sweden.
- Sports & Recreation