Hosts Brazil will open their bid for a first Olympic men’s football title against South Africa after Thursday’s draw was made in the Maracana Stadium.
Brazil, three-time runners-up including in 2012, have won every title apart from the Olympics and are drawn in the same Group A as South Africa, Iraq and Denmark.
“I’m very confident, I’m sure that Brazil will succeed in the Games,” said veteran Ronaldinho, winner of bronze in Beijing 2008, who attended the draw ceremony.
Holders Mexico are in Group C along with Germany, South Korea and Fiji while Group D includes Honduras, Algeria, Portugal and Argentina. European under-21 champions Sweden have been drawn alongside Colombia, Nigeria and Japan.
Contrary to the women’s competition the men’s teams are made up of under-23 players with three players over that age allowed.
Clubs however are not obliged to release their players for the competition which does not appear on FIFA’s official calendar although the world body organises the event.
Three-time defending women’s champions the United States were drawn against France in the first round.
The reigning world champions are in Group G along with third-ranked France, New Zealand and Colombia.
Top ranked United States have won three of the four titles since the women’s tournament was first introduced at the 1996 Atlanta Games.
Germany, ranked number two in the world by FIFA and three-time silver medallists, were drawn in Group F alongside Canada, Australia and Zimbabwe.
Brazil’s women’s team begin their campaign against China at the Estadio Olimpico in Rio de Janeiro on August 3, while the men kick off against South Africa at the Estadio Mane Garrincha in Brasilia the following day.
The top two teams in each group qualify for the knockout stage, with the top two third-placed teams also progressing.
Group A: Brazil, South Africa, Iraq, Denmark
Group B: Sweden, Colombia, Nigeria, Japan
Group C: Fiji, South Korea, Mexico, Germany
Group D: Honduras, Algeria, Portugal, Argentina
Group E: Brazil, China, Sweden, South Africa
Group F: Canada, Australia, Zimbabwe, Germany
Group G: United States, France, New Zealand, Colombia