Melbourne has been dislodged by Vienna for the first time at the top of the Economist Intelligence Unit’s global liveability index, strengthening the Austrian capital’s claim to being the world’s most pleasant city to live in.

The two metropolises have been neck and neck in the annual survey of 140 urban centres for years, with Melbourne clinching the title for the past seven editions. This year, a downgraded threat of militant attacks in western Europe as well as the city’s low crime rate helped nudge Vienna into first place.

Vienna regularly tops a larger ranking of cities by quality of life compiled by the consulting firm Mercer. It is the first time it has topped the EIU survey, which began in its current form in 2004.

The struggle for Melbourne: has the world's 'most liveable' city lost its way? Read more

At the other end of the table, Damascus retained last place, followed by the Bangladeshi capital, Dhaka, and Lagos in Nigeria. The survey does not include several of the world’s most dangerous capitals, such as Baghdad and Kabul.

“While in the past couple of years cities in Europe were affected by the spreading perceived threat of terrorism in the region, which caused heightened security measures, the past year has seen a return to normalcy,” the EIU said on Tuesday.

“A long-running contender to the title, Vienna has succeeded in displacing Melbourne from the top spot due to increases in the Austrian capital’s stability category ratings.”

Vienna and Melbourne scored maximum points in the healthcare, education and infrastructure categories. But while Melbourne extended its lead in the culture and environment component, that was outweighed by Vienna’s improved stability ranking.

Osaka, Calgary and Sydney completed the top five in the survey, which the EIU says tends to favour medium-sized cities in wealthy countries, often with relatively low population densities. Much larger and more crowded cities tend to have higher crime rates and more strained infrastructure, it said.

London ranked 48th this year.

Vienna, once the capital of a large empire rather than today’s small Alpine republic, has yet to match its pre-first world war population of 2.1 million. Its many green spaces include lakes with popular beaches and vineyards with sweeping views of the capital. Public transport is cheap and efficient.

In addition to the generally improved security outlook for western Europe, Vienna benefited from its low crime rate, the survey’s editor, Roxana Slavcheva, said.

“One of the sub-categories that Vienna does really well in is the prevalence of petty crime ... It’s proven to be one of the safest cities in Europe,” she said.