RIO DE JANEIRO — With fireworks forming the word “Rio” in the sky and supermodel Gisele Bundchen shimmering to the tune of “The Girl from Ipanema,” Rio de Janiero welcomed the world to the first Olympic Games in South America with a serious message underlying the celebration: Let’s take care of our planet.

After one of the roughest-ever rides from vote to games by an Olympic host, the city of beaches, carnival, grinding poverty and sun-kissed wealth opened the two-week games of the 31st Olympiad with a high-energy gala celebration of Brazil’s can-do spirit, biodiversity and melting pot history.

The low-tech, cut-price opening ceremony, a moment of levity for a nation beset by economic and political woes, featured performers as slaves, laboring with backs bent, gravity-defying climbers hanging from the ledges of buildings in Brazil’s teeming megacities and — of course — dancers, all hips and wobble, grooving to thumping funk and sultry samba.

But Brazil also packaged its party with solemnity, lacing the fun and frivolous show with sobering messages about global warming. Images of carbon dioxide, a greenhouse gas, swirling in the Earth’s atmosphere were followed by projections of world cities and regions — Amsterdam, Florida, Shanghai, Dubai — being swamped by rising seas. The peace symbol, tweaked into the shape of a tree, was projected onto the floor of the Maracana Stadium that filed with thousands of athletes from the 207 teams.

The crowd roared when Bundchen sashayed from one side of the 78,000-seat arena to the other, as Tom Jobim’s grandson, Daniel, played his grandfather’s famous song about the Ipanema girl “tall and tan and young and lovely.”

In a video preceding the show, UN Secretary-General Ban Ki-moon said the games “celebrate the best of humanity” and appealed for an Olympic truce, calling on “all warring parties to lay down their weapons” during the two weeks of sporting achievement.

advertisement | advertise on newsday

There were times after the International Olympic Committee selected Rio ahead of Chicago, Tokyo and Madrid in 2009 when it seemed that the city of 6.5 million people might not get its act together for the world’s greatest sporting mega-event. The spreading health crisis of the mosquito-born Zika virus kept some athletes away. Promises to clean up Rio’s filthy waters remained unfulfilled. The heavy bill for the games, at least $12 billion, made them unpopular with many. Heavily armed security stopped a small group of protesters from getting close to the stadium ahead of the ceremony.

But with more than a dash of “gambiarra,” the Brazilian art of quick-fixes and making do, Rio is ready.

The honor of declaring the games open falls to Michel Temer, Brazil’s unpopular interim president, standing in for suspended President Dilma Rousseff. Her ouster less than four months out from the games for alleged budget violations was one of the many complications that roiled Brazil’s Olympic preparations and impacted the opening ceremony itself. Fewer than 25 foreign heads of state were expected.

@NewsdaySports

Greece, the historical and spiritual home of the games, led the march by athletes into the stadium. They were being joined by a first-ever Refugee Olympic Team of 10 athletes, displaced from Syria, South Sudan, Congo and Ethiopia.

With “USA” emblazoned on the back of his jacket, Michael Phelps carried the flag for the U.S. team, the largest with 549 competitors. At his fifth and last Olympics, it was the first time the record holder of 22 medals had marched in an opening ceremony, having skipped previous ones to save energy for competition.