In the middle of the 19th century, an area the size of Germany located between Beijing and Shanghai in central China was run for more than 15 years by the Nian rebels, a 50,000-strong network of bandit groups who lived by pillage and rape. The inability of the Imperial armies to quell the rebellion for so long was a sign of the system's vulnerability that would eventually lead to its collapse.

Importantly, the Nian bandits were men without women, long understood in China as the principal stimulus to their rebellion and cause of their violence. They originated in a district in northern China - Huai-pei - where the killing of infant girls to conserve food for more economically valuable boys in response to famine had been particularly terrible.

By 1850, the official records show that there were 129 men to every 100 women, an astonishing imbalance in the ratio between the sexes. Lower-class Huai-pei peasants could not find wives; hungry, economically displaced and, in Chinese terms, 'bare branches' - not proper men because they could not marry and father children - they turned to banditry as providing meaning and sustenance alike.

Those womanless bandits cast a long shadow over not just today's China, but the whole of Asia. Asia is estimated to suffer from up to 100 million missing women - aborted as foetuses or murdered in infancy because of their sex. Pakistan, erupting in protests last week against President Musharraf's anti-democratic high-handedness in suspending a senior judge, is a volatile tinderbox where the capacity for such insurrection to spread is everpresent.

Fanning the flames of injustice and Islamic fundamentalism is the country's sex imbalance. Dispossessed, displaced men with no prospect of ever finding a partner more readily take to the streets like Nian rebels; violence demonstrates masculine meaning.

In today's China, there are now 119 men for every 100 women. In some areas, the imbalance is greater than it was in Huai-pei in 1850. Earlier this year, an official Chinese report projected that by 2020, one in 10 men between 20 and 45 would be unable to find a wife. Professor Valerie Hudson of Brigham Young University in the US estimates that by 2020, there will be 28 million surplus Chinese men and 31 million surplus Indian men.

Both governments are becoming more and more worried about the psychological and social consequences, not to mention the sheer criminality of it. As one Indian commentator remarks, the most dangerous period of a woman's life is her first few months in the womb. China's President Hu Jintao, remembering the Nian rebellion, has publicly recognised that such a huge population of 'bare branches' constitutes one of the biggest potential threats to the communist regime's survival. Real unemployment in China is more than 20 per cent, inequality is growing rapidly and there is plenty of injustice for rootless, violently inclined, womanless men to protest about.

For its part, the Indian government is increasingly alarmed by the explosion of woman trafficking and prostitution, and the threat to the rule of law implied by such mass infanticide and abortion of babies because of their sex. In the last few weeks, it has stepped up its campaign to make the battery of laws against such practices stick.

It is illegal in India to require a wife's family to pay a dowry to her future husband's family, a disastrous disincentive for poor peasants to be the parents of girls; illegal to use ultrasound equipment to establish the sex of an unborn baby; illegal to perform abortion because of a baby's sex. Yet the practices are on the increase, with the use of ultrasound becoming ubiquitous.

The problem is that peasant societies economically and culturally value boys - and India and China remain peasant societies. Wives go to live with men in their villages; it is through men that the blood line continues; it will be your son's family that looks after you in old age. In rural China, where there is no pension system for 800 million people, terror of old age with no carer or pension is rampant, accentuated by the one-child system.

If your one child is a girl, she will marry out and you face an old age of desolation and neglect. The incentive to abort or kill the baby girl and try for a boy is immense. It is nearly always the mother, aware of the disadvantage of being a woman, who commits the crime, which makes policing so very hard.

You might expect hard economics would provide some counterbalance; as women become scarcer and their co-equal and vital part in constructing healthy societies ever more obvious across Asia, you would expect their value to rise. Yet the mores of marriage trump economics. Daughters move out to live in the villages of sons, so that sons continue to be more valuable.

Rather than women in general being valued more in the face of a woman shortage, what is happening is that lower-class women are marrying further up the social scale. In India, dowries are rising, not falling, as the average income of marrying couples increases. What is left behind, just as in Huai-pei, is an ever-growing pool of men at the bottom who are both poor and without the prospect of finding a wife.

In both China and India, there is a near complete correlation between the growth of violent crime and those cities and provinces where the sex ratio is worst. It is Indian provinces such as Uttar Pradesh and parts of the Punjab that have both the worst sex imbalance and highest levels of recorded crime. Chinese cities such as Shanghai or Guangzhou report 90 per cent of crime from unmarried migrant men.

Most Chinese regimes in history, as the communists know, have been toppled from below. Western commentators like to project China and India as economic giants effortlessly on the move. But societies that are so dysfunctional rarely sustain rapid growth or stable government for long. There will be change. The questions are how and when.

· Will Hutton's recent book on China, The Writing on the Wall, is published by Little, Brown, £20