LIKE the hero of “The Iliad”, China can seem invincible. In 2010 it overtook America in terms of manufactured output, energy use and car sales. Its military spending has been growing in nominal terms by an average of 16% each year for the past 20 years. According to the IMF, China will overtake America as the world's largest economy (at purchasing-power parity) in 2017. But when Thetis, Achilles's mother, dipped her baby in the river Styx to give him the gift of invulnerability, she had to hold him somewhere. Alongside the other many problems it faces, China too has its deadly point of unseen weakness: demography.

Over the past 30 years, China's total fertility rate—the number of children a woman can expect to have during her lifetime—has fallen from 2.6, well above the rate needed to hold a population steady, to 1.56, well below that rate (see table). Because very low fertility can become self-reinforcing, with children of one-child families wanting only one child themselves, China now probably faces a long period of ultra-low fertility, regardless of what happens to its one-child policy. The government has made small adjustments to the policy (notably by allowing an only child who is married to another only child to have more than one child) and may adapt it further. But for now it is firmly in place, and very low fertility rates still prevail, especially in the richest parts of the country. Shanghai reported fertility of just 0.6 in 2010—probably the lowest level anywhere in the world. According to the UN's population division, the nationwide fertility rate will continue to decline, reaching 1.51 in 2015-20. In contrast, America's fertility rate is 2.08 and rising.

The difference between 1.56 and 2.08 does not sound large. But over the long term it has a huge impact on society. Between now and 2050 China's population will fall slightly, from 1.34 billion in 2010 to just under 1.3 billion in 2050. This assumes that fertility starts to recover. If it stays low, the population will dip below 1 billion by 2060. In contrast, America's population is set to rise by 30% in the next 40 years. China will hit its peak population in 2026. No one knows when America will hit its population peak.

The differences between the two countries are even more striking if you look at their average ages. In 1980 China's median (the age at which half the population is younger, half older) was 22. That is characteristic of a young developing country. It is now 34.5, more like a rich country and not very different from America's, which is 37. But China is ageing at an unprecedented pace. Because fewer children are being born as larger generations of adults are getting older, its median age will rise to 49 by 2050, nearly nine years more than America at that point. Some cities will be older still. The Shanghai Population and Family Planning Committee says that more than a third of the city's population will be over 60 by 2020.

This trend will have profound financial and social consequences. Most obviously, it means China will have a bulge of pensioners before it has developed the means of looking after them. Unlike the rest of the developed world, China will grow old before it gets rich. Currently, 8.2% of China's total population is over 65. The equivalent figure in America is 13%. By 2050, China's share will be 26%, higher than in America.

In the traditional Chinese family, children, especially sons, look after their parents (though this is now changing—see story on next page). But rapid ageing also means China faces what is called the “4-2-1 phenomenon”: each only child is responsible for two parents and four grandparents. Even with high savings rates, it seems unlikely that the younger generation will be able or willing to afford such a burden. So most elderly Chinese will be obliged to rely heavily on social-security pensions.

China set up a national pensions fund in 2000, but only about 365m people have a formal pension. And the system is in crisis. The country's unfunded pension liability is roughly 150% of GDP. Almost half the (separate) pension funds run by provinces are in the red, and local governments have sometimes reneged on payments.

But that is only part of a wider problem. Between 2010 and 2050 China's workforce will shrink as a share of the population by 11 percentage points, from 72% to 61%—a huge contraction, even allowing for the fact that the workforce share is exceptionally large now. That means China's old-age dependency ratio (which compares the number of people over 65 with those aged 15 to 64) will soar. At the moment the ratio is 11—roughly half America's level of 20. But by 2050, China's old-age ratio will have risen fourfold to 42, surpassing America's. Even more strikingly, by 2050, the number of people coming towards the end of their working lives (ie, those in their 50s) will have risen by more than 10%. The number of those just setting out (those in their early 20s, who are usually the best educated and most productive members of society) will have halved.

Help wanted

The shift spells the end of China as the world's factory. The apparently endless stream of cheap labour is starting to run dry. Despite pools of underemployed country-dwellers, China already faces shortages of manual workers. As the workforce starts to shrink after 2013, these problems will worsen. Sarah Harper of the Oxford Institute of Population Ageing points out that China has mapped out the age structure of its jobs, and knows for each occupation when the skills shortage will hit. It is likely to try to offset the impact by looking for workers abroad. Manpower, a business-recruitment firm, says that by 2030 China will be importing workers from outside, rather than exporting them.

Large-scale immigration poses problems of its own. America is one of the rare examples of a country that has managed to use mass immigration to build a skilled labour force. But America is an open, multi-ethnic society with a long history of immigration and strong legal and political institutions. China has none of these features.

In the absence of predictable institutions, all areas of Chinese society have relied on guanxi, the web of connections that often has extended family relations at the centre. But what happens when there are fewer extended families? One result could be a move towards a more predictable legal system and (possibly) a more open political culture. And, as shifts in China's economy lead to lower growth, Chinese leaders will have to make difficult spending choices; they will have to decide whether to buy “guns or walking sticks”.

China is not unique in facing these problems. All rich countries have rising pension costs. And China has some advantages in dealing with them, notably low tax rates (giving room for future increases) and low public expectations of welfare. Still, China is also unusual in two respects. It is much poorer than other ageing countries, and its demographic transition has been much more abrupt. It seems highly unlikely that China will be able to grow its way economically out of its population problems. Instead, those problems will weigh down its growth rate—to say nothing of the immense social challenges they will bring. China's Achilles heel will not be fatal. But it will hobble the hero.