But Hungary's coach Denes Kemeny said his side had played at 60 percent of their best form and signalled lessons needed to be learned.
"We are happy with the result. We are not happy with all the aspects of the game," he said.
Russia, who advanced to the quarter-finals, scored three goals in the last quarter but were unable to catch Hungary.
Athens 2004
Last-minute miracle for Italy
24/08/2004 AT 16:05
SLAMMED HOME
Greek centre fielder Theodoros Chatzitheodorou slammed home a goal with 2:05 left to break a 4-4 tie with Italy.
Centre fielder Anastasios Schizas added an insurance goal with 57 seconds to go, sending an overflow home crowd at the main Olympic pool into ecstasy.
Spain, Germany and Serbia and Montenegro join Russia in the quarter-finals. Spain beat winless Egypt 12-4 in a Group B game on Monday to advance.
Germany went into the medal round after a 6-6 tie with Group B rivals Australia. The advance ensures Germany of their best Olympic result since they finished fourth at the 1988 Seoul Games.
Driver Aleksandar Sapic scored three goals to help Serbia and Montenegro beat United States 9-4 in a Group A game.
Spain will play Serbia and Montenegro and Russia faces Germany in quarter-final play on Wednesday. The finals are on Sunday.
Croatia also defeated Kazakhstan 5-4 for fifth place in Group A.
Under Olympic rules, the top team in each of the two groups goes directly to the semi-finals. The next two teams play a quarter-final round.
Tokyo 2020
USA continue women's water polo dominance with third straight Olympic gold
07/08/2021 AT 09:52
Water Polo
Top 10: Olympic water polo goals
26/04/2021 AT 22:29