Students wearing masks burn flares during a protest demanding better education and protesting the money spent on the Olympics in Rio de Janeiro, Brazil, on July 6. (Silvia Izquierdo/AP)

The state of Rio is so broke it is selling off the governor’s summer residence and the small island it sits on. But because of a recent federal government bailout, officials insist, the Summer Olympics will go just fine.

The problem is what happens after the Games.

“One isolated measure does not resolve the problems of the state,” said Leonardo Espíndola, the governor’s chief of staff. “The crisis affects all sectors.”

The state government’s dire financial situation has clouded preparations for South America’s first Olympic Games, which open here Aug. 5. Rio is running a deficit of about $6 billion a year, Espíndola said in an interview last week, and has lurched from one crisis to another since last year, when state hospitals ran out of basic supplies.

Struggling to pay salaries and pensions and keep public entities operating, officials resorted to apocalyptic rhetoric to force money out of the central government and avert an Olympics disaster.

In April, Espíndola warned of imminent “social collapse.” In June, acting governor Francisco Dornelles, sitting in for Gov. Luiz de Souza, who is undergoing cancer treatment, declared a “state of public calamity in financial administration.” Espíndola said Dornelles’s move was decisive in freeing up $870 million from the federal government that, coupled with austerity measures, stabilized the situation.

Now, officials say, everything is in place for Rio to stage a memorable Olympics — although many observers doubt even that. Most of the bailout was used to cover security costs and pay outstanding salaries to police, firefighters and prison officers. Less than a month before the Games begin, some emergency health centers have reduced their hours and are struggling to pay suppliers. Teachers are on strike. Police and firefighters have twice staged demonstrations at Rio’s international airport, warning that visitors’ safety cannot be guaranteed and protesting still-unpaid salaries.

Residents in some areas have donated toilet paper, cleaning products and even fuel to police stations low on supplies, said Ferdando Bandeira, director of a union of investigating officers. “The conditions are a little precarious,” he said.

A recently retired police sergeant, who spoke on the condition of anonymity because of the sensitivity of the issues facing the state, said the Olympics would not be safe for visitors despite the deployment of 85,000 soldiers and police officers.

Instead, he said, local commanders may choose to deal with the leaders of the armed drug gangs that control many of the low-income communities, called favelas, where much crime is concentrated. If drug lords bring down the number of robberies in an area, he said, police leave the drug trade alone.

“This happens,” he said. “It’s practice.”

Meanwhile, some Rio residents are already using a new cellphone app launched by Brazil’s Amnesty International branch to avoid places where gunfights have happened. It is called Fogo Cruzado, Portuguese for crossfire.

‘Palliative measures’

The concern, however, is that even if the Games proceed smoothly, disaster has been merely postponed. Another police sergeant, speaking on the condition of anonymity because he was not authorized to give interviews, characterized the bailout as a short-term fix at best, and one aimed at security personnel.

“This was for us to work during the Olympics, to shut us up,” he said. “We don’t know what will happen afterward.”

Espíndola acknowledged as much, saying that cuts and government bailouts were “palliative measures” and that bigger structural changes are needed, including amending laws to allow the state to reduce its crushing pension burden.

Brazil’s generous pension laws allow some public servants to retire as young as 50, further burdening many states facing financial difficulties. Rio has more retired staff than workers, Espíndola said, and their costs represent more than half of the state’s deficit. But Rio is worse off than most, according to José Afonso, a researcher with the Getulio Vargas Foundation’s Brazilian Institute of Economics, because it also depends heavily on tax revenue from oil production — and oil prices have plummeted.

A gargantuan corruption crisis at the state-run oil company, Petrobras, headquartered here, also has resulted in less construction of oil platforms and rigs and has hit supplier companies in Rio, with a knock-on effect for the state.

Rio’s oil revenue has fallen from a fifth of its income to 10 percent in two years, Afonso said.

And the state has been hit by the recession that is affecting the country as a whole, Brazil’s worst in decades. Interim president Michel Temer made austerity measures his main platform after taking over from Dilma Rousseff, who is currently suspended from office pending a controversial impeachment trial.

“The scenario is bleak for the coming years,” Afonso said.

For visitors and athletes who stay within the main Olympic areas, Rio’s crisis may become visible only if they get sick or fall victim to crime.

The budgets of the state’s emergency health centers have been almost halved, said Rubem Fernandes, director of a nonprofit group called Viva Rio, which manages six of them.

“We reduced the number of doctors, nurses, assistants,” Fernandes said. “But we have more queues.”

However, the federal government has contracted with 2,500 extra medical professionals for the Rio Games, based in six federal hospitals. Two state hospitals were taken over by the city government, which is responsible for most Olympic venues and is in much better financial shape.

Transportation concerns

Some critics say corruption factors into Rio’s financial mess. A key collaborator in the Petrobras scandal has accused both former Rio governor Sérgio Cabral and his former deputy and successor, the ailing de Souza, of bribery worth millions of dollars around contracts for an oil refinery.

Other collaborators have reportedly said that Cabral, who ran Rio until 2014, was paid bribes on contracts for Rio’s new $2.7 billion metro line. Both men have denied the allegations.

Some $90 million of the recent federal bailout went toward partially finishing the line, financed with French and Brazilian government loans and slated to open with limited service just four days before the Games. Some transport experts said this leaves little time for tests with passengers. Rio’s bid document promised the line by 2014.

Construction “should have been completed,” said Paulo Ribeiro, a transport engineering professor at the Federal University of Rio. “As it wasn’t, I hope it is secure.”

Alexandre Rojas, a professor in transport engineering at the State University of Rio, said tests normally would last two or three months. But he said the line would meet international safety standards.

Rio’s transport secretariat said the line will be operated manually during the Games and accessible only to passengers with Olympic credentials and event tickets. It will close during the Paralympics that follow and begin an automatically operated service in late September for four hours a day.

The situation around the metro line is a sign of how, away from its gleaming new venues, Rio might scrape through the Olympics, separating visitors from its poorer inhabitants.

Another such sign came on July 4, when Mayor Eduardo Paes inaugurated the city’s third bus rapid-transit, or BRT, line, linking Games areas to the rest of the city. It connects Barra de Tijuca, a neighborhood in Rio’s west, to a second Olympic hub in Deodoro, in the city’s gritty “West Zone,” passing favelas and low-income neighborhoods.

“This changes people’s lives,” said Paes. He said the state’s financial crisis and security concerns were “not a problem.”

Like the new metro line, this BRT line will be available during the Games only to those with Olympic credentials and tickets. For the rest of the population, access to both will come afterward, just as the post-Olympic hangover is kicking in — provided the state can come up with the funds to finish work on the much-needed train line.