Hosts Britain, taking part in their first Olympic soccer event since 1960, will kick off the bid for gold against Senegal at Manchester United's Old Trafford on July 26 after the draw was made at Wembley on Tuesday.
Senegal reached their first Olympics after beating Oman 2-0 in a playoff at the City of Coventry Stadium on Monday.
Britain will also meet Uruguay and United Arab Emirates in Group A.
Brazil, five-times World Cup winners but never Olympic champions, face Egypt, Belarus and New Zealand in Group C.
Spain, gold medallists in 1992 and the reigning world and European champions, take on Japan, Honduras and Morocco in Group D while seeded Mexico meet South Korea, Gabon and Switzerland in Group B.
The first event of the Olympics takes place at Cardiff's Millennium Stadium on July 25, two days before the opening ceremony, when the British women's soccer team play New Zealand in Group E. Cameroon and Brazil are in the same section.
Women's world champions Japan face Sweden, South Africa and Canada in Group F while Olympic champions United States take on France, Colombia and North Korea in Group G.
The women's final is at Wembley on August 9 followed by the men's two days later.
(For more sports news and updates, follow Ahram Online Sports on Twitter: @AO Sports)