RIO DE JANEIRO — If there was a nation in need of an uplifting spectacle at this moment, even in the form of a public relations exercise, it was Brazil.
The first South American country to host the Olympics is reeling from an astonishing combination of political upheaval and economic crisis. Its efforts to stage the world’s biggest sporting event met trouble at every turn, from the Zika virus to polluted waters to budget cuts so deep that basic operations became strained.
So the opening ceremony of the Summer Games arrived Friday night as a salve, disguising the wounds for a few hours and letting Brazilians celebrate everything from the waves of immigrants still putting down stakes here to Alberto Santos-Dumont, the aristocratic bon vivant whom Brazilians credit with inventing the airplane.
Over the past several Olympic cycles, the gigantic cost of hosting the Games has drawn as much attention as the athletic performances. Host countries like China and Russia have used the Olympics as a show of force. The vibe, and the budget, are different here. These are a no-frills, budget-conscious Olympics — even if the opening ceremony dazzled.
“The show was magnificent, its portrayal of Brazil’s history through images and movement,” said Luís Gustavo da Silva Teixeira, 24, a worker at a car factory who watched the ceremony at a cafe in Rio. “I don’t know if it’s something my children will witness again in this country of ours so I feel fortunate.”
The organizers of the ceremony even chose a word in Portuguese, gambiarra, to describe their own efforts to put on a show amid Rio’s pared-down Olympic ambitions. Translating the word, which is pronounced GAHM-beeah-hah, poses its own challenges, so they offered a few options: jury-rig, quick fix, do a MacGyver.
Unpredictability marked even the lighting of Olympic caldron. The soccer legend Pelé was thought to be a likely candidate until Vanderlei Cordeiro de Lima, who was leading the marathon at the 2004 Athens Games when he was tackled by a spectator, carried out the honor.
Extolling achievements like Rio’s pioneering replanting of its urban forests and the tolerance, however fragile, that characterizes much of Brazilian society, a message emanated from the opening ceremony: Some order and progress, the words optimistically emblazoned on the country’s flag, might just emerge from the creative chaos that persists here.
Pointing to the ceremony’s honoring of Brazil’s achievements as a racially diverse nation and its call for action to combat global warming, Fernando Meirelles, the director of “City of God” — about Rio’s favelas, the gritty urban areas that largely formed as squatter settlements — and one of the event’s creative directors, proudly proclaimed that it would rankle conservative figures at home and abroad. Political leaders certainly hope that the Olympics will be a turning point in the fortunes of Brazil and Rio, whose quest to host the Olympics began in the early 1990s — a time when the city was wallowing in crisis, enduring a long decline after authorities built Brasília, the new capital, from scratch deep in the country’s interior and transferred much of the federal bureaucracy there in the 1960s.
Still, the I.O.C. frequently frustrated Rio’s ambitions. It was only in 2009, when Brazil’s star was on the rise as its economy prospered from a commodities boom, that Rio was finally awarded the Games. Elated crowds celebrated on Copacabana.
“I’ve never felt more pride in Brazil,” Luiz Inácio Lula da Silva, the country’s president at the time, said when Rio got the Games. “Now, we are going to show the world we can be a great country.” But much has changed since that exuberant day. Brazil’s economy is mired in its worst recession in decades.
Rio is grappling with a resurgence of violent crime. And colossal corruption scandals are casting a pall over the nation’s political establishment. The city’s preparations for the Olympics were marked by a long string of fiascos, including the recent collapse of an oceanfront bicycle path that killed two men.
Mr. da Silva, universally known as Lula, did not even attend the opening ceremony — he is instead preparing for a trial on charges that he tried to obstruct an inquiry into a massive bribery scheme at Petrobras, the national oil company. Mr. da Silva’s protégée and successor, Dilma Rousseff, who was suspended as president to face an impeachment trial, also skipped the show. Instead, it was the interim president, Michel Temer — who had emerged victorious in a power struggle in May — in attendance.
A loud chorus of boos greeted Mr. Temer in the Maracanã stadium when he spoke briefly to officially declare the start of the Games.