Hungary, who won the gold medal for the third time in a row at Beijing 2008, have advanced to Rio 2016 ©Getty Images

Nine-time Olympic champions Hungary survived a late scare to beat Germany 8-7 and qualify for Rio 2016 at the men's Olympic water polo qualifying tournament in Trieste today,

With the four semi-finalists all qualifying for the Games, quarter-finals day was of the utmost important at the Polo Natatorio Bruno Bianchi in the Italian city.

Hungary, who progressed through Group A as winners after four victories and a draw, were heavy favourites against a Germany side who squeezed through in fourth place from Group B after just one victory.

It was far from routine for Hungary, however, as the country who won the Olympics three times in a row from 2000 to 2008 were made to work hard against a German side who only finished 11th at this year's European Championship in Belgrade.

Canada were beaten by Spain in Trieste
Canada were beaten by Spain in Trieste ©Giorgio Scala/FINA

Hungary finished third at that tournament and led 5-2 after the first two periods today.

That advantage was extended to 7-3 at the end of the third, but the Germans scored four times in the final stanza, compared to the Hungarians' one, to set up the nervy finale.

Spain also qualified for Rio as they edged out Canada 8-7 in another close contest.

The Spanish also survived a 4-1 reverse in the last quarter after leading the Canadians 7-3 at the end of the third.

A third game finished 8-7 as hosts Italy secured their Rio spot by beating Romania.

France needed penalties to beat The Netherlands in another thrilling clash.

After an 8-8 draw, the French booked their place in Rio 4-3 via the shoot-out.