THIS is London's year. In June the city put on damp but impeccably organised Diamond Jubilee celebrations; in July it hosts the Olympics. Barring terrorist attacks and transport disasters (not a small risk, given that the organisers are relying on public transport) the games should reinforce the city's sense that it is on top of the world.

Yet London's position is more precarious than it feels. The city's success over the past quarter-century has been the consequence of historical accident and good policy. Now history is moving on, and the policymakers are messing up. They could tip the city into a decline without even noticing it, for the ecosystem of a great city is a complex and fragile thing.

De profundis

London has resisted Britain's relative decline. While the country has slipped to seventh place in the league of world GDP, the capital is first, or second to New York, in most of the rankings of great cities. If it were not for London, Britain would be off the map for both businessmen and tourists.

It wasn't always thus. After a boom in Victorian times, the city went into a decline from the beginning of the second world war. Bombing, the waning of manufacturing, the closure of the docks and government policies designed to reduce the city's dominance were responsible. By the late 1980s the population had shrunk by a quarter.

Then things turned around again. It was probably in part the gravitational pull of a great city reasserting itself, but as our special report in this issue explains, it was also the replacement of daft policies with good ones. In the 1970s the government stopped trying to push growth elsewhere; in the 1980s the Big Bang liberalised the financial-services industry and drew in workers and money from around the world. A convenient time zone and a language which imperialism had spread around the globe made it easy for foreigners to operate in the city. A trustworthy legal system and a clean polity made it a good place to do business. Excellent universities and private schools attracted young people and parents.

Thus globalisation, distilled and concentrated in London, turned the place into the world's most international city. New York has as many foreign-born people as London—a bit more than a third—but its businesses look to America, whereas London's look out to the world. And whereas New York's immigrants are mostly huddled masses, London attracts the smart professionals and the stinking rich as well. Its elite is increasingly made up of foreigners, or the children of foreigners.

For Londoners, this has a downside. Per square foot, property in London is more expensive than anywhere except Monaco. While property prices in other capitals, and in the rest of Britain, have fallen during the economic crisis, demand for central-London property from emerging markets has pushed prices in the city up still further.

There is a larger upside. Partly because foreigners are better-qualified, younger and—according to surveys of employers—harder-working than the locals, and because of the flow of foreign money into the city, London's economy has done much better than Britain's in recent years. Value-added per head in London is now one-and-three-quarters what it is in the country as a whole; and, as a result, London subsidises the rest of the country to the tune of £15 billion ($23 billion) each year.

But there is a hitch. Although Britain lives off London, and London lives off foreigners, Britain does not much like foreigners. Out of people from six rich countries recently polled, Britons were the most hostile to immigration. And that is not because they see so many immigrants. London, which is one-third foreign-born, is far warmer towards them than the rest of the country, where only 8% like them. Nor is this simply because migrants favour migrants: even British-born white Londoners are friendlier to foreigners than other Britons.

Study "The Knowledge", our interactive guide to London's demography and economy

London also cannot determine its own future. Its mayor has few powers. It is ruled by the rest of the country, and by a Conservative prime minister brought up in the foreigner-free Berkshire countryside. Pressure on David Cameron from his right wing, and the rise of immigration up the list of voters' concerns, has led him to promise to cut immigration to “tens of thousands” a year—a tough job, when net migration was 252,000 last year. Students' right to work is being restricted, making study in Britain less affordable; acquiring business visas is becoming harder; getting family members into the country is increasingly difficult. The Labour Party's attitude is much the same: last week its leader, Ed Miliband, said his party had “got it wrong” in allowing so much immigration.

Stay open to stay great

This is a great time for London, but its moment will inevitably pass. The accumulation of capital from the empire and the industrial revolution made the place prosper; and now, with the rise of the emerging markets, capital is accumulating elsewhere. Europe's traumas, however they are resolved, will shape its future, either because it is bound more tightly into the continent, or, more likely, because it floats away from it.

Yet although the government cannot prevent the city's relative decline, it can affect its speed. The cost of housing is not just a problem for Londoners, but also a tax on business. Higher property taxes, which are desirable on wider economic grounds, would cut demand for property as an investment or a second home. Allowing more development both on brownfield sites in the city and on the Green Belt encircling it would increase supply; though beloved by environmentalists and nimbys, the Green Belt pushes growth further into the south-east, thus damaging a larger area of countryside. Transport needs to be improved by investing in rail, widening congestion-charging and expanding airport capacity.

Most of all, Britain needs to stop discouraging foreigners from coming. London's prosperity is built on its ability to attract the rich, the clever and the hard-working from all over the world. Anything that jeopardises the city's internationalism endangers its future, and anything that jeopardises London endangers the country.