Home favourites Greece booked their place in the semi-finals of the men's water polo after a 6-4 win over Italy. Defending champions Hungary also joined the hosts in the last four thanks to two goals from Gergely Kiss in their tense 7-6 win over Russia.
A hat-trick from Aleksandar Sapic helped Serbia-Montenegro into the last eight after a 9-4 victory over the USA.
They will face 1996 champions Spain, while Germany, who drew 6-6 with Australia on Monday, will play Russia.
The draw put Germany in second place in Group B, ensuring their best Olympic result since they finished fourth at the 1988 Seoul Games.
Spain had an easy 12-4 victory over Egypt, who failed to win a single game in the tournament.
The top team in each of the two groups go directly to the semi-finals, with the next two teams in each pool playing off for the remaining spots in the last four.
There were scenes of celebrations in the Olympic pool as Greece overcame second seeds Italy in a dramatic Group B match.
Centre fielder Anastasios Schizas scored the hosts' sixth and final goal with just 57 seconds on the clock, sending the partisan crowd into ecstasy.
Defending champions Hungary maintained their unbeaten record - but only just.
Coach Denes Kemeny said his side played at only 60% of their capability and needed to improve upon their performance against Russia.
"We are happy with the result, but we are not happy with all the aspects of the game," he said.