With both sides locked on two points going into the game and only one spot in the last eight remaining, Serbia enjoyed the better start and were 7-4 to the good midway through the first half, thanks to three unanswered goals.
But with a huge Hungarian backing in the Copper Box, Lajos Mocsai's team reduced the deficit to two at the break, going in 11-9 down, and then set themselves up for victory with a pulsating second-half performance.
They scored five of the first eight goals after the restart to bring the scores level and then six of the next seven to build up a commanding lead that Serbia were never going to be able to claw back.
Serbia did reduce it to three by the end, but Hungary saw it out to book a likely quarter-final tie against Iceland and send their opponents packing.
Tamas Mocsai threw in nine goals for Hungary, while Momir Ilic and Rajko Prodanovic scored five apiece for Serbia as the morning's session started with a bang.