Years ago, when Medellin was the murder capital of the world, police detective Lina Molina said she would easily respond to half a dozen or more homicides in an eight-hour shift.

But as the clock struck 4 on a recent morning, she yawned and tried to stay awake as her team of investigators waited for a radio dispatch of a code 9-0-1, a homicide. There had been none in 16 hours, even though it was the start of a three-day holiday — the kind of night when people are drinking and fighting and street-hardened detectives expect killings to take place.

“We would get 19 or 25 homicides in a weekend, years ago,” said Molina, who’s been investigating homicides and other serious crimes for 18 years.

These days, there are far more dangerous cities in the world. The vast majority are in Latin America and the Caribbean, where the cocaine trade, easy access to illegal arms and weak judiciaries help fuel the violence.

No. 1 is San Pedro Sula in Honduras, which recorded a homicide rate of 169 per 100,000 in 2012. Of the 50 cities with the highest homicide rates, 15 are in Brazil. Venezuela’s capital, Caracas, records far more homicides than any other city in the world, nearly 4,000 in 2012.

Medellin was once in a league of its own, racking up 6,349 killings in 1991, or 380 murders per 100,000 people, when the drug kingpin Pablo Escobar had put a bounty on the heads of police officers and vowed to bring the city to its knees. The homicide rate has since fallen by 80 percent, making this city a model that attracts politicians and police officials who come from as far away as South Africa, Rio de Janeiro and Washington to see how officials engineered the transformation.

And yet, as Molina pointed out, slow nights in Medellin can be fleeting.

“When we get to seven murders in a day, we say, ‘Oh God, what’s happening?’ ” she said.

As May wound down, the city already had 470 slayings for the year, giving it a homicide rate that still was among the highest in Colombia and ranked among the 30 most violent cities in the world.

‘This is our headache’

As police radios crackled in the background, Maj. Hector Gutierrez, head of the police investigative team in the city, looked over crime reports on a recent night. Muggings were down in the city over the year before, he noted, and so were car thefts. Motorcycle thefts were way up.

But he was worried about murders, which he said were stubbornly high.

“This is our headache,” he said, and pointed to the Candelaria district on a map, where killings were way up over 2012. “So what are we doing? We’re hitting the Candelaria hard — the extortion business, the street crime.”

Deploying more police officers to problem districts has worked here and in other cities as far away as New York. Medellin’s anti-crime formula, though, included a range of programs that improved life in problem neighborhoods and made the city more inclusive for the once-forgotten poor, said Mayor Anibal Gaviria, who called the changes here “a metamorphosis.”

New schools were built and old ones remodeled in the city’s so-called Comunas, the toughest districts. New libraries, lauded for their modernist architecture, also went up alongside new parks and public squares.

Because neighborhoods climb up steep hillsides, city officials installed lifts and gondolas to carry thousands of people down from distant barrios to Medellin’s immaculate metro. In Comuna 13, where soldiers and Marxist guerrillas battled a decade ago, a series of escalators were installed, giving residents the chance to step on and ride up, listening to piped music, instead of having to hoof it up 1,300 feet.

The initiatives, Gaviria said, gave residents a new sense of pride and made the streets safer while facilitating the presence of the state in dangerous districts.

“The situation with violence has gotten much better, and violence has gone down,” said Jairo Chalarca, 58, who lives in a barrio where gangs still roam. “It’s not just more police but lots of investment on social issues, because violence against violence isn’t the solution.”

Fear and silence

Still, Medellin officials have also found that the gains on crime and violence can be ephemeral.

In 2007, the city recorded 771 killings for a homicide rate lower than Washington’s. But by 2011, it was back up to 1,649 homicides. The number has since fallen fast once more, but gang expert Luis Fernando Quijano said the sharp rise and fall suggest that gang leaders may be fighting less, not that the state has control.

Quijano said that more than 9,000 people fled their homes last year because of crime and that an untold number of people reported missing may be dead. He said that low-level extortion of small businesses is pervasive, and that the shadowy leaders of drug gangs remain on the loose.

“This city has never really made the decision to strike a blow against the gang structures,” Quijano said.

The Medellin of the distant past seems to come alive in San Cristobal, where three gang members died fighting one another on its lush hillsides recently. Thugs then drove more than 200 people out of their homes. The residents returned only with soldiers carrying assault rifles.

Catching his breath as he trudged up San Cristobal, Arnulfo Serna, the city’s secretary of security, said residents had been threatened, instilling in them fear that they would pay with their lives for helping the police.

“The threats and intimidation cause many people not to report crime, or to collaborate with the authorities,” he said.

The presence of the state had led Maria de Los Angeles Posada, 75, to return to her home after nearly a month away. The city had posted a red seal on her door that served as a message to would-be intruders: “This home is being protected.”

“Until now, we do feel safe,” she said, sitting in her living room as pint-size grandchildren giggled nearby. “But who knows what it will be like later when they leave. That is what we are all thinking about, and it’s making us afraid.”