Rio de Janeiro is hosting the summer Olympics. Here’s why there’s reason to celebrate – and worry in Brazil. (Lee Powell/The Washington Post)

On a recent morning, Andrea Pereira was taking in the wonders of the Olympic renovations in Rio, riding a sleek new train downtown with her family to the gleaming new “Wonderful Port.” And yet she felt bombarded by mixed feelings.

Her city — the pulsing, jubilant, unequal, crime-addled world champion of sunny celebrations — did seem prettier now that the Summer Games were about to begin.

But the 40-year-old military police officer has spent three months worrying over late or partial paychecks amid the state government’s budgetary fiascos. Her 16-year-old nephew won’t be attending Friday’s Opening Ceremonies because the family fears a terrorist attack. Teachers have been on strike. Violence is rising in the favelas. The nation’s president has been ousted.

“They put makeup on the downtown. But that’s not our reality,” Pereira said. “We feel ­betrayed.”

On Oct. 9, 2009, when the International Olympic Committee selected Rio de Janeiro to host the 2016 Summer Games, confetti fell over a delirious crowd on Copacabana Beach and then-President Luiz Inácio Lula da Silva wept with joy. This was a country poised to knock on the First World’s door, an economic powerhouse with boundless natural wealth, the leader of a peaceful region.

Explore the neighborhoods and meet the people of a city transformed to host its first Olympics.

The ensuing years have wiped away the smiles.

“There was a moment of megalomaniacal euphoria,” former president Fernando Henrique Cardoso said in an interview. “As if Brazil had already solved its problems, already belonged in the First World.

“Now we are in doubt: Are we really capable or not?”

Brazil’s once-booming economy, fired up by commodity sales to China, spending by a rising working class and dreams of offshore oil wealth, has plummeted into recession and the country’s political class — including Lula — has become embroiled in corruption scandals. His successor, Dilma Rousseff, has been suspended from the presidency and is awaiting an impeachment trial. Her successor, Michel Temer, is deeply unpopular; he has said he expects to be loudly booed when he shows up for the Games.

Rio also has not been able to keep many of its promises for the Olympics. Polluted bays and lagoons have not been cleaned; construction is over budget and sometimes slipshod.

Throw in wild cards — say, the 166,000 cases of the Zika virus in Brazil and fears of terrorism, and it is obvious that South America’s first Olympics is coming at a very complicated ­moment.

Rio de Janeiro knows how to party on a monumental scale while throwing an international sporting event. The city hosted soccer’s World Cup two years ago and the Pan American Games before that. Yet the mood is apprehensive, almost queasy. A recent poll found that nearly 2 out of 3 Brazilians expect the Olympics to bring more losses than benefits. Soldiers wearing camouflage are posted at bridges, subway platforms and beaches.

The green and yellow shirts of Olympic volunteers are branded with “361°” — for the manufacturer — which is supposed to mean “one degree beyond” but also conjures an image of someone spinning in place, off balance and just out of control.

Instability beneath the shine

Some of this city’s new makeup has been beautifully applied. The streets around the port along Guanabara Bay used to be dingy, with homeless people sleeping amid decrepit, graffiti-tagged warehouses. The Olympics have transformed that area into the “Porto Maravilha,” its centerpiece a stunning plaza anchored by the Museum of Tomorrow with its soaring mechanical wings. An elevated highway was torn down to make room for a broad pedestrian boulevard that is lined with colorful murals and warehouses converted to house exhibits on Brazilian culture.

“It’s really changed; it’s beautiful,” said Mayara Tenorio, a 24-year-old actress, as she watched her sister perform ballet in the plaza for passing tourists. “I hope the Games will rebuild our patriotism and love for the country.”

Although some infrastructure projects were delayed, the city’s public transportation options improved, with the government adding nearly 100 miles of bus rapid transit lines, an additional subway line and a new light-rail line. There are new saucer-shaped stadiums. The city’s giant statue of the Olympic rings is located in Madureira Park on the poorer north side of the city, in an area that was a blighted lot.

Alexandre Costa, a 40-year-old who runs a restaurant, sat with his back against a tree in the park, eating ice cream and watching his daughters play. “This used to be a neighborhood without good spots for families,” he said. Now there are concerts, a skate park, fountains and outdoor ­restaurants.

At the same time, Costa said he has noticed a distinct drop-off in his business as unemployment has risen.

“The whole place feels ­unstable,” he said.

A ‘schizophrenic government’

Across town, an anti-Lula, anti-Rousseff protest was moving down the palm-lined street along Copacabana Beach. It looked small, a few thousand people, and also very Brazilian. How to judge the size? Was the woman in the cherry-colored spandex with the giant promotional can of Red Bull strapped to her back a protester? Or the guy with the shaved chest and Speedo sauntering through the crowd?

The messages people carried, however, were serious: “We do not want communists in Brazil” and even “I love military intervention,” referring to Brazil’s two decades of military rule. In 1970, Rousseff was jailed and tortured as a young woman for joining a left-wing guerrilla movement opposed to the dictatorship.

“During the military regime, we didn’t have this mess in Brazil,” said Alvaro Arthur, a 66-year-old retired marine carrying a banner calling for a military ­takeover.

Although expressing a minority sentiment in the country, the protesters reflected a backlash against 15 years of leftist policies in which the government spent heavily on social programs to help the poor. Temer has indicated a desire to privatize state-owned companies and has named more conservative ministers to his cabinet.

“This is a schizophrenic government,” said Walter Salles, the well-known filmmaker who directed “Central Station” and “The Motorcycle Diaries.” Although Temer says he wants to pursue allegations of the misuse of government funds to benefit politicians, Salles noted, his party has talked about blocking such ­inquiries.

Neither Rousseff nor Lula plans to attend the Opening Ceremonies on Friday. Rousseff’s impeachment trial is expected to take place during the Games.

For Lula, winning the Olympics crowned a remarkable run as a popular, two-term leader. During 2010, his last year in office, Brazil’s gross domestic product grew by 7.5 percent, the fastest rate in a quarter-century. Since then, he has been accused of obstructing an investigation into the corruption scandal at the state-run oil company, Petrobras, as well as benefiting from a real estate scheme. Lula acknowledged that his expectations for this moment “were better” when he pursued the Games.

“Today, Brazil is living through difficult economic times, a political crisis, and an attempt to consolidate a parliamentary coup d’etat that threatens to reverse social rights won by the poorest and by workers,” Lula wrote in response to questions from The Washington Post, using an expression — coup — that Rousseff’s supporters use to describe her impeachment.

Nonetheless, he said, the Games are a time for ­celebration.

“This moment in Brazil might be difficult, with a lot of misinformation, unjust accusations and resentment, but it will pass and we will return to the path of democracy, social inclusion and economic growth,” he added.

Fears of local crime

“I’m afraid of terrorism,” taxi driver Elias Alves said as he wove through Rio. “Imagine the Islamic State blows up a train or something; it would be a ­disaster.”

These types of fears used to have no place in Brazil, a country without a history of attacks by Islamist extremists. But Brazil plans to deploy about 88,000 soldiers and police to maintain security during the Games. Authorities last month arrested a dozen people suspected of planning a terrorist attack during the Games.

Alexandre de Moraes, the justice minister, who oversees security, said in an interview that he was pleased with the intelligence work done by Brazil and dozens of other countries cooperating with his country.

“The probability of an act happening in Brazil, at the Olympics, is very small, according to all the international agencies,” he said. Still, he said, a “lone wolf”-style attack is possible.

Most residents seem to worry about more-pedestrian violence, such as the turf wars between rival drug gangs and police that have plagued the city for years. Behind the row of multimillion-dollar beachfront apartments and hotels in Copacabana, the steep hillside is crowded with shanties.

A year before Brazil was awarded the Olympics, police in Rio launched an ambitious program to combat drug trafficking in this and other favelas. The Police Pacifying Units, as they were known, set up bases inside the communities for constant patrolling. David Bispo credits this police presence with paving the way for the success of Bar do David, a restaurant in the favela that has won international attention.

“I got famous and my business succeeded because foreigners and tourists could come,” he said.

But he said that business has fallen off by 70 percent because of the recession and what he calls the recent “violence crisis” in the neighborhood. The police presence has waned with the economic recession, he said, and budget cuts have led to protests and strikes by the force.

With unemployment rising, more people come into his restaurant looking for jobs, but they aren’t available. Food prices for basics such as milk and beans have shot up, said Alexandre Medina, a cook at a community center in the favela. He would have loved to see Olympic soccer in person, but that will remain a fantasy.

“The Games are for those who have money,” he said. “We’re not invited to this party.”