Defending champion Spain will play its opening World Cup game against the Netherlands, a repeat of the 2010 final, while host Brazil faces a relatively easy path to the knockout stage after Friday's draw.
The United States was drawn into the toughest group with Germany, Portugal and Ghana.
"Difficult draw, but a group the U.S. can get through if they play well," former U.S. coach Bruce Arena told The Associated Press.
Brazil starts its campaign for a sixth World Cup title with an opener against Croatia. Mexico and Cameroon are also in the group.
Bosnia-Herzegovina, the only World Cup newcomer among the 32 teams, plays its opener against Argentina. Iran and Nigeria were also drawn in that Group F.
Colombia, Greece, Ivory Coast and Japan are in Group C, with Uruguay, Costa Rica, England and Italy in a strong Group D.
One of the easiest groups on paper looked to be E, with Switzerland, Ecuador, France and Honduras.
Russia, host of the next World Cup, is in Group H with Belgium, Algeria and Korea.