RIO DE JANEIRO — Preparations for Rio’s troubled Olympic Games suffered another blow this week when hundreds of agents with Brazil’s National Force, a key security unit brought in for the event, threatened to quit over poor accommodation and working conditions.

The National Force is Brazil’s equivalent of the U.S. National Guard and is made up of police officers and firefighters from across the country. During the Olympics, this unit will be responsible for protecting arenas and other event locations. But Tuesday, hundreds of National Force agents held a meeting outside the government complex where they are housed, with many urging fellow officers to quit. The meeting was preceded by a noisy protest.

“Everyone wanted to leave. The conditions were very bad,” said an out-of-state police officer on the force, speaking on the condition of anonymity because of fear of disciplinary measures for talking publicly without authorization.

The unrest is particularly worrying as violent crime is rising across Rio state and concerns about security during the Olympics, which officially opens Aug. 5, are increasing. Up to 500,000 international visitors are expected.

A "pacification" policy to install police bases in low-income communities, called favelas, long dominated by armed drug gangs is crumbling in some areas. Shootouts and armed robberies are on the rise. Stray bullets have killed three people in the past two days alone.

The police officer said the unit's personnel had gone through a rigorous selection process to work for the National Force during the Olympics as part of a wider 85,000-strong security force that includes troops.

The National Force personnel arrived June 22 at their new barracks — a public housing complex in west Rio, near the main Olympic site — and found there was no furniture. Some apartments lacked showers and had mold and damp on the walls and ceilings, as well as toilets without lids. There were areas that stank of sewage and even electricity shortages.

“There were no beds. We had to organize airbeds or simple mattresses,” the officer said. “Everyone wanted to go home.”

To compound the problem, the complex is situated close to two favelas — both run by rival criminal gangs. “This is not a place where a security professional should be,” the officer said.

Another National Force agent fumed over conditions in a letter sent via WhatsApp to Brazil’s national union of private and noncommissioned officers in the police and fire services. (In Brazil, street police and fire brigades are structured like military units).

“The success of the mission is at risk!” the letter read. “Morale is low and this could come at a high price.”

Some agents complained that they were working up to 16 to 20 hours a day and not getting a full day off. Others said they had not been paid the daily food allowance of $70. Others said the number of shifts was too high, with some working 80 hours a week. On Tuesday, matters reached a boiling point.

“They had already been complaining for a number of days, and yesterday was the final straw,” said Elisandro Lotin, the union's president, said Wednesday.

On Wednesday, Lotin met with Celso Perioli, Brazil’s national secretary of public security, to air the grievances. “He guaranteed that he was already taking measures to resolve the problems," Lotin said. Beds would be sent and outstanding payments made.

“The structure for the security of Olympic installations is guaranteed, as are the daily allowances for professionals from the National Force of Public Security that will act in the Olympic Games and Paralympics,” a spokesman for the Justice Ministry said in an email. He did not give his name, in accordance with internal regulations.

The police officer initially cited confirmed that some payments had been received and some beds delivered.

The officer also said that the number of shifts had been reduced but that the force had been told it was a temporary move because the government was unable to recruit enough police officers. Local media have reported that 5,000 National Force agents will be at hand, instead of the 9,600 earlier envisioned. More troops will be deployed instead.

“There is a shortage of police all over Brazil,” the officer said. “There will be a cost for those working, because it will be heavy. But we will manage.”