Hungary booked their place in the semi-finals by beating Russia 11-10 in a thrilling encounter.
With the scores tied after three quarters, the Hungarians - going in search of their first Olympic Games medal in the women's event - clinched the final period by a single goal.
There were emotional scenes at the Water Polo Arena as the fourth-placed team from Beijing 2008 celebrated victory, and Russia came to terms with defeat.
Gabriella Szucs, Hanna Kisteleki, Dora Czigany and Dora Antal each scored a brace for Hungary. Rita Keszthelyi, Barbara Bujka and Ildiko Toth netted one apiece.
Evgeniya Ivanova fired in four for Russia, as Ekaterina Lisunova and Olga Beliaeva scored two each.
There was an even more dramatic conclusion later on in the day, as Australia beat China 4-2 in a penalty shoot-out after the scores had been locked at 16-16.
The team from Down Under clinched the contest with their fifth penalty throw after four quarters of normal time and two extra-time periods could not separate the teams.
Glencora Ralph and Nicola Zagame scored hat-tricks for Australia, while Gemma Beadsworth, Holly Lincoln-Smith, Kate Gynther and Ash Southern each netted twice.
Ma Huanhuan found the back of the net four times for China, while Fei Teng and Sun Huizi scored hat-tricks.
Australia progress to play the United States, who powered to a 9-6 victory over Italy.
A final-four spot keeps the USA in the hunt for their first Olympic Games gold, after reaching the podium in every Games since the sport was introduced at Sydney 2000.
Italy started strongly, scoring a penalty with just 17 seconds gone, then doubling their lead with a long-range effort.
But the USA hit back, with Melissa Seidemann scoring a hat-trick for the winners.
In the final game of the night, Spain edged out Great Britain 9-7, but they were pushed all the way.
Team GB came back from a four-goal deficit to get within one score of their opponents in the closing minutes, but it was the Spaniards who booked a place in the semis.