OPINION: In the mid-19th Century, two devastating floods of the Yellow River, and the famine that followed, ravaged northeastern China.

Outlaw bands, known as nien, attracted young men in unprecedented numbers, aggregating into militias that wrought chaos on the troops and infrastructure of the ruling Qing. Although this Nien Rebellion and the larger Taiping rebellion in the South were eventually crushed, they devastated the Chinese economy and contributed to the ending of the Qing dynasty.

According to political scientists Valerie Hudson and Andrea den Boer, widespread female infanticide during the famine meant that as many as one quarter of young men in the region were "bare branches" -- as the Chinese expression goes -- unlikely ever to bear fruit. The Nien rebellion, they argued, was propelled by these surplus young men who had so few other prospects.

This story of the Nien Rebellion foreshadows one of the biggest issues that China will face in coming decades: the dramatic excess of young men.

A long history of son preference, particularly among the Han majority, has led to female infanticide and the neglect of daughters in some parts of China. But in recent decades, the spread of cheap ultrasound (enabling sex-determination in early-mid pregnancy) and easy access to abortion courtesy of the government's one-child policy, has led to the widespread abortion of female fetuses.

As a result, approximately 30 million more men than women will reach adulthood and enter China's mating market by 2020. The scale of this current sex-ratio bias dwarves that in the Nien rebellion, and the consequences could turn out to be more catastrophic.

Young men with poor prospects of ever starting a family spell danger to themselves and to their societies. Over millions of years of evolution, large numbers of women and even larger numbers of men left no offspring at all. Yet everyone alive today descends from ancestors who managed to avoid that fate. Our male ancestors were the ones who strove most frantically for status and the respect of their peers, and who won the chance to mate.

As a result, young men are hair-trigger sensitive to their circumstances, and when the number of men who will never find a mate rises, so does the intensity of the striving. Young men discount their futures and take ridiculous risks in order to improve their prospects. They also become more violent, rising more readily to perceived slights and insults, and starting more fights -- often over trivial issues. These are the triggers for most man-on-man assaults and homicides.

Many factors contribute to the number of men who will never find a mate. Economic inequality, for one, leaves a great many poor young men unable to attract a wife. When a society allows powerful men to take several wives, too few women remain for many poor men to take even a single wife. But most dramatically of all, male-biased sex ratios consign the excess men to never having a family of their own.

Under each of these scenarios, large numbers of young men competing for dominance elevate local rates of violence, homicide and lawlessness. Martin Daly and Margo Wilson's studies show that local income inequality can explain variation in homicide rates on a number of scales: from Chicago neighborhoods to American States and Canadian provinces.

Throughout history, a surplus of young men often heralded violence. The American frontier earned its "Wild West" reputation for lawlessness because its towns overflowed with men, yet marriageable women were vanishingly rare. In The Chivalrous Society, historian Georges Duby argued that European expansionism, from the Crusades to colonialism, was fuelled by a surplus of ambitious and aggressive young men with otherwise poor reproductive prospects.

China is already feeling the effects of so many bare branches. The economist Lena Edlund estimates that every one percent increase in the sex ratio results in a six percent increase in the rates of violent and property crime. In addition, the parts of China with the most male-biased sex ratios are experiencing a variety of other maladies, all tied to the presence of too many young men. Gambling, alcohol and drug abuse, kidnapping and trafficking of women are rising steeply in China.

The bare branch problem will be compounded as income inequality rises. China's Gini coefficient of income inequality has risen from less than 0.3, 25 years ago, to almost 0.5 today. On the Gini scale, 0 represents perfect equality while a score of 1 represents complete inequality.

It would be difficult to overstate the urgent need for China to emulate South Korea in eliminating sex-biased abortion and neglect.

But just as urgently, China needs creative large-scale solutions to the problems that unprecedented cohorts of bare branches will cause as they come of age over the next two decades. Those millions of disaffected young men will not only present a danger to themselves, but those living alongside them. And, as Hudson and den Boer have been arguing for some time, the bare branches will also make perfect fodder for political agitation, fundamentalism and possibly terrorism.

Rob Brooks is a Professor of Evolutionary Biology at UNSW.

This opinion piece was first published on CNN.com