UNTIL a few years ago, no outsider would have dared to set foot in Comuna 13, once the most dangerous neighbourhood in Medellín, Colombia’s second city. Now travel agencies offer tours to look at the district’s many murals, or to ride the long outdoor escalator built to ascend the steep flanks of the valley in which the city of 2.4m people sits. Such excursions are not just for tourists; mayors from all over the world are trekking to a city that has become a model of urban development. How did the “Medellín miracle” happen? And what can it teach other cities?

Medellín’s recipe looks simple. It used to be the world’s murder capital, the hometown of Pablo Escobar, an all-powerful drug lord. The solution was a radical urban makeover with a redistributive purpose: the best projects were reserved for the poorest, most violent areas. “The point was to bring together a fragmented society and show respect for the most humble,” says Sergio Fajardo, the city’s mayor in 2004-07, who is credited with pioneering what city wonks call “social urbanism”.

The first step to understanding this approach is to buy a ticket for Medellín’s overground metro. The system is not just a means of transport, but also a statement of intent. It is squeaky clean; graffiti is nowhere to be seen; each platform has its own security guard; passengers are constantly reminded to queue. Some stations have libraries, others double as concert venues. “People are the city’s raw material. You need to educate them,” says Ramiro Márquez, the boss of the metro.

When it first opened in 1995, after years of delay, the metro mainly linked the north and south of the valley. To connect the poorest districts, which clung to the valley’s sides, the city also built two aerial cable-car lines. It used the stations of this system as anchors for ambitious “integrated urban plans”—a combination of new buildings, public spaces and social programmes, all developed with input from local residents.

A ride on the line above the city’s north-eastern district gives a sense of what has been achieved. One station, Santo Domingo, is at the centre of a cluster of new schools, bridges and parks—as well as the futuristic Biblioteca España (now shrouded for construction work, but pictured above), a cultural centre complete with galleries, auditoriums and libraries.

Medellín’s problems remain severe. In 1991, a rich resident earned 21 times more than a poor one; in 2010 the multiple was 56. El Poblado, the district for the rich, feels like Singapore; Popular, the poorest neighbourhood, is reminiscent of the slums of Dhaka. But poverty in the city has fallen in recent years: 19.2% of residents now live below the official poverty line, less than the average in Colombia’s metropolitan areas. The homicide rate, which peaked at 381 per 100,000 people in 1991, has dropped to fewer than 50 per 100,000.

Unfortunately for those visiting mayors, Medellín’s transformation was largely caused by two particular factors. First, the city has a ready source of money, which paid for much of its social urbanism. The Empresas Públicas de Medellín (EPM) is one of South America’s best-run utility companies. In 2013 it generated nearly $869m in profits on revenues of $6.9 billion—$640m of which ended up in the city’s coffers. In the past ten years EPM has sent $3.2 billion to city hall, around 25% of the municipal budget. The paisas, as the locals are called, cherish their utility: politicians mess with EPM at their peril. “There is a massive social control of what we do,” says Juan Calle, the firm’s chief executive.

The second resource that the city draws on is a unique political and economic culture, which some have called “Catholic corporatism”. Whether because of the character of early waves of immigrants (often Jesuits and Basques), the fact that it sits in an isolated valley in one of South America’s most mountainous regions or the eternal competition with Bogotá, the country’s capital, Medellín’s elites have long collaborated to make their city thrive.

City of eternal spring

This tradition of co-operation was crucial in enabling Medellín to overcome its crisis, argues Angela Stienen, a social anthropologist at the University of Education in Bern, Switzerland. During the 1990s the inner circle was broadened, she says. Representatives from business, the municipality, NGOs, unions, universities and even some gang members regularly met to discuss the future of the city. These roundtables spawned both ideas and a new generation of local leaders, such as Mr Fajardo and Alonso Salazar, who served in 2008-11.

Even taking a page or two from Medellín’s book will be difficult, therefore. And the city is not short of its own challenges, as the development model shifts. A tram and two more cable-car lines are being built, connecting poor districts in the city’s east. But other plans seem decidedly more urban than social: a green belt around the city, new metro lines, a river park and an “innovation district”, which already boasts a huge centre for startups and other technology firms. There is talk of becoming a Silicon Valley of the south.

For these visions to really bear fruit, Medellín will have to open up, says Julio Dávila, an urban-policy expert at University College London. The city’s strong culture has drawbacks, such as a reluctance to do business with strangers and a tendency not to think beyond the rim of the valley. Asked what keeps him up at night, Mr Calle of EPM, which has a growing business abroad, replies without missing a beat: “Everyone is in love with their city. They don’t want to work abroad.”