RIO DE JANEIRO (Reuters) - The United States secured a berth in the quarter-finals of the men's Olympic volleyball tournament by defeating Mexico on Monday, while an ecstatic home crowd roared Brazil on to the next round with a 3-1 win over France.

The United States, gold medalists in Beijing in 2008, clawed their way back from the brink of elimination in Rio after losing their first two games to Canada and Italy.

They began the turnaround with a 3-1 win over Brazil, beat France by the same score, then defeated Mexico (25-23 25-11 25-19) in their last preliminary game to set up a quarter-final against Poland.

"The big challenge was having such emotional matches the previous two and being able to summon those emotional reserves and come out and to bring that again," said U.S. coach John Speraw.

Brazil sent France home after recording a 25-22 22-25 25-20 25-23 win at Rio's packed Maracanazinho stadium, where Brazilian supporters booed every French serve and roared with delight when the home team scored.

"The champions are back," the crowd chanted of Brazil, Olympic gold medalists at the 2004 Athens Games.

French coach Laurent Tillie said his team made too many mistakes on their serve.

"We were up against a very good team. We fought and tried to find our way tactically, but Brazil made no mistakes at the end of the sets," he told Reuters.

Tillie said the crowd was noisy but fair and France had enjoyed the sporting atmosphere.

Brazil, beaten finalists at the last two Olympics, face sporting arch-rivals Argentina in the quarters. Defending champions Russia play Canada and Italy play Iran.

Canada defeated group leaders Italy 3-1 on Monday.

(Reporting by Anthony Boadle; Editing by Bill Rigby/Peter Rutherford)