The authorities also grapple with murders that settle scores between street dealers and cocaine users over drug-related debts, with Amazonas registering a homicide rate of 50.1 per 100,000 inhabitants in 2012, up 157 percent since the start of the century and almost twice Brazil’s national rate.

Officials say they were able to reduce the homicide rate in Manaus in 2013, largely by expanding police patrols in poor areas. But most murders in the city are still thought to be related to drugs as the prison gangs wield their clout, according to Débora Mafra, an investigator with the Amazonas Civil Police.

Manaus is surrounded by rain forest and has only about a tenth of the population of the metropolitan area of São Paulo, Brazil’s largest city. Yet the fraying security adds to a dystopian feel in some areas, with luxurious new residential towers and a futuristic World Cup soccer stadium standing near canals reeking of sewage and squatter settlements fleeced of trees.

Reflecting the precarious living conditions across big stretches of the city, Manaus ranks last among Brazil’s 16 largest cities in the United Nations Human Development Index, a comprehensive measure of economic, life expectancy and other statistics.

In many corners of Manaus, users can buy oxy or crack for as little as $2 a rock, and some consume their purchases openly in broad daylight, smoking the drugs in pipes made from aluminum cans. Whether belonging to drug gangs or operating on their own, dealers ply their trade in what amounts to a Hobbesian contest to meet demand.

“Getting drugs in Manaus is easy,” said Francisco Edinaldo da Silva Pereira, 34, an unemployed taxi driver and recovering addict. “These days you go into a bar, start drinking and when you least expect it you find someone in that bar who sells,” he explained. “It’s like that in every neighborhood.”