For McDonald’s, which replaced its chief executive in March, the move also represents an opportunity to connect with consumers as it tries to turn around its corporate identity. As news of the migrant crisis has flooded the mainstream news media, Steve Easterbrook, McDonald’s new chief executive, said the company wanted to show that it could respond to issues its customers cared about.

Image Images from the commercial, "Stop Hunger. Start Peace."

“We felt it was an opportunity for us to contribute something meaningful, something authentic,” Mr. Easterbrook said. “This is not about single brands. This is about doing good.”

The announcement also comes about a month after Burger King challenged McDonald’s to team up and create a “McWhopper,” a combination of the fast-food chains’ hamburgers, that would help raise money for the nonprofit group Peace One Day. Mr. Easterbrook rebuffed the challenge in messages on Facebook and Twitter, but said he would “be in touch.”

The World Food Program is under increasing pressure to help respond to the millions of Syrians, Iraqis and others displaced from areas of conflict. Tens of thousands of migrants have fled to Europe, which has scrambled to respond to the influx.

Providing much-needed food assistance and other aid would help ease the desperation that has pushed thousands west, said Jay Aldous, the food program’s director of private sector partnerships. Companies including Google, Twitter and United Airlines have agreed to contribute paid TV time or access to digital promotion for the food program, according to the organization.