Brazil has a well-deserved reputation for violent crime. It is so pervasive that people routinely alter their behavior to reduce the odds of being victimized. Stopping at red lights at night? Better not. Thinking of wearing jewelry? Leave it home. Carrying cash? Bring no more than you need and can afford to lose.

Crime also is a symptom of the broader civic distress that is driving the protests that continue to erupt in some major cities. Since Brazil seems unable or unwilling to root out the corruption that makes it difficult to develop decent infrastructure, policing and social services, it's worth asking how it will get a handle on the crime problem.

A new report by the Center for Latin American Studies makes clear just how endemic violent crime is. The headline number is shocking: Between 1980 and 2011 there were 1.15 million homicides in Brazil. That's almost the population of Dallas, Texas. The carnage claimed more than 52,000 lives in 2011, the latest year with data used in the study.

Although a handful of smaller countries have higher murder rates, no major nation matched Brazil's 27.4 per 100,000 in 2011. The U.S., by comparison, had 5.3 per 100,000, or about 16,000 homicides. Only Mexico, which is riven by brutal drug-gang warfare, comes close with a rate of 22.1.

To be sure, Brazil has its share of drug gangs, made famous in films such as "City of God," though the report doesn't attribute most of the killings to the narcotics trade. Instead, the violence seems to spring spontaneously from minor disputes among neighbors, spouses, friends and acquaintances.

A case in point was a savage double murder in the northeastern state of Maranhao a few weeks ago, in which a man refereeing an amateur soccer game fatally stabbed a player who objected to a penalty call. Friends of the dead player attacked the referee, dismembering and decapitating him. Most homicide victims are men and almost three-quarters are black, the study found. More than half of Brazil's population is of African descent, a legacy of the nation's history as the Western country with the largest slave population.

Brazil's big cities -- Sao Paulo and Rio de Janeiro -- have large numbers of homicides, though the rate has been dropping. In the country's north and northeast, crime is exploding.
It isn't hard to see why. States such as Bahia, Para, Rio Grande do Norte and Paraiba were once largely rural. Today, expanding cities draw in people from the countryside. Many wind up crowding into squatter settlements known as favelas, where conditions are often squalid and services non-existent. Lingering racism leaves large swaths of the population ill-educated and ill-prepared to function in a modernizing economy. Add in a country with a yawning gap between the rich and poor and you have a combustible mix.

The soaring crime rates also reflect the pathologies of those who are supposed to fight it: the police. Police officers in Brazil are often poorly trained and badly paid, particularly outside the biggest cities. They often participate in and profit from crime. They also mete out brutal street justice. The combination breeds cynicism and distrust.

If there are signs of optimism, they can be found in Sao Paulo, where homicides have declined by almost two-thirds in the past decade, and Rio de Janeiro, where murders fell by 38 percent in the same period, the study found. Both cities have experimented with forms of community policing, using what are known as Police Pacification Units, which establish a permanent presence in the poorest neighborhoods. Local and regional governments have also focused on bringing services to these neglected areas, integrating them into the fabric of the city.

There is skepticism about whether these improvements will be sustained after Brazil hosts the World Cup in 2014 (FIFA, the international governing body for soccer, has expressed concern about the crime rate) and the Summer Olympics two years later. In the meantime, there are lessons for leaders in cities where crime has found such hospitable terrain.

(James Greiff is a member of Bloomberg View's editorial board. Follow him on Twitter).