BETWEEN getting out of his car and starting work in the morning, Bashir Akinyele, a beret-wearing history teacher in Newark, New Jersey, passes the sites of two murders. His school, Weequahic High, once taught Philip Roth, a giant among America’s novelists. Its entrance is now blocked by a metal detector; armed cops share the corridors with teenage girls. In the streets nearby almost every intersection has been the site of a shooting. “I’ve been a teacher for 20 years,” says Mr Akinyele. “And in that time, I’ve lost 38 students.” Weequahic is only 30 minutes’ drive from Manhattan, but a world apart. In 1991 Newark and New York City had roughly the same murder rate: 32 and 29 per 100,000 respectively. But by last year New York’s rate had fallen to four and Newark’s had jumped to 40, according to the latest data published on November 14th by the FBI. On a night out in Brooklyn, the main threat is getting caught in a boring conversation with a hipster. In Newark, when darkness fell, your correspondent was ushered back downtown by police.

Over the past 20 years, crime has fallen spectacularly in America and across the rich world. The FBI data suggest it is still falling: violent crime decreased by 4.4% between 2012 and 2013, and murder is now less common than at any time since the end of the 1950s. Criminologists have countless plausible theories to explain this, ranging from less lead-poisoning to the rise of car immobilisers. Yet the difference between cities such as Newark, which remain dangerous, and those like New York, which are safe, suggests a somewhat subtler explanation.

In Washington, DC the murder rate has dropped from a terrifying 81 per 100,000 in 1991 to a fifth of that now. In Los Angeles gang warfare has largely given way to organic coffee bars, and burglaries and robberies have become rare. Yet cities like Philadelphia and Chicago have experienced more modest improvements. And in places like Baltimore, Newark and Detroit some crime rates have barely fallen.

One possible explanation is the varying quality of local government. In New York and Los Angeles, reformers such as Rudy Giuliani, who was New York’s mayor in the 1990s, and Bill Bratton—chief of police in both cities at different times—forced cops out of their cars, adopted data-driven policing and tried to make public spaces feel safe. They reckoned that residents had to trust the police for crime to fall—which meant purging corruption—and that criminals had to be deprived of convenient places to hang out.

In Newark, by contrast, Sharpe James, the mayor until 2006, was imprisoned in 2008 on fraud charges. His successor, Cory Booker, now a Democratic senator, did much to attract investment into downtown Newark, and managed for a short time to reduce crime and overhaul the police department; but the money ran out, and he later had to cut the force sharply. The present mayor, Ras Baraka, a more traditional rabble-rouser, has hired new cops, but the police force remains troubled (it is, uniquely, monitored by the federal Justice Department). When The Economist visited, the new police director and police chief led officers on a “community walk” around a sketchy neighbourhood. They seemed to spend much of their time telling people how excellent the new mayor is.

Some think that too much prison breeds nastier criminals: when released, they may be more dangerous than when they went in. In Philadelphia most homicides stem from stupid arguments, often between ex-convicts, says Lieutenant John Stanford of the local police. Newark has 278,000 people yet, each month, 1,400 prisoners are released from the local jail.

However, incarceration rates are high throughout America, so this cannot explain the specific ills of its most crime-ridden cities. Nor can poverty: unemployment in New York City is not much lower than it was in the 1990s. Rather, according to John Roman, a researcher at the Urban Institute, a think-tank, crime is like a contagious disease. People who are vulnerable to criminality—poor, badly-educated young men—are far more likely to become criminals when they are surrounded by men much like themselves.

Although cities like New York and Los Angeles have plenty of poor people, they are—by American standards—not unusually segregated by race or income. The presence of ambitious new immigrants in deprived neighbourhoods provides an inoculation against crime. In Weequahic, by contrast, deindustrialisation led to depopulation. Whites and many middle-class blacks have fled. Those who remain are mostly poor and desperate. Low property prices provide little incentive for people to clean up blight.

Even in the most dangerous cities, however, there is hope. Urban populations are now growing across most of the country. In Philadelphia crime rates, though still high, dropped sharply last year. At a police town-hall meeting in the west of the city, people complain about noisy bars, troublesome children and illegal parking. A new charter school and a growing student population are changing the neighbourhood. Shootings are still frighteningly common, admits the local police captain, but milder worries are creeping in.