Shame on us Chinese! Last Thursday a two-year-old girl was run over twice, about 100 metres from her home in a hardware market district of Foshan, a prosperous city in southern China. As she lay on the ground, writhing in pain, before being hit by the second vehicle, 18 people, on their bicycles, in cars or on foot, passed by but chose to ignore her. Among them a young woman with her own child.

Finally, a 58-year-old female rubbish collector came to the girl's rescue, but it was too late. By the time she was brought to the hospital, the girl Yueyue, (whose name translates as Little Joy), was brain dead. She was declared dead early on Friday morning. She was a good girl, full of life, her mother said a few days ago in an interview. She said she had just brought Yueyue back from her kindergarten. She popped out to collect the dry clothes and returned to find Yueyue gone – probably trying to look for her elder brother.

It might have been a different story if one of the 18 people had lent Yueyue a hand. None even bothered to call for emergency services. Later, when interviewed by a journalist, one of the passersby, a middle-aged man riding a scooter, said with an uncomfortable smile on his face: "That wasn't my child. Why should I bother?"

Before giving himself up to the police, the driver of the second vehicle, a van, told the media why he had run away. "If she is dead, I may pay only about 20,000 yuan (£2,000). But if she is injured, it may cost me hundreds of thousands of yuan." What's wrong with these people? How could they be so cold-hearted? The horrific scene was caught by a surveillance camera and has been watched by millions of viewers since it was posted on Youku, China's equivalent of YouTube.

This is only the latest incident where tragedy has struck as a result of the callous inactivity of onlookers. Last month an 88-year-old man fell over face down at the entrance of a vegetable market near his home. For almost 90 minutes, he was ignored by people in the busy market. After his daughter found him and called an ambulance, the old man died "because of a respiratory tract clogged by a nosebleed". If anyone had turned him over, he might have survived.

Both cases, the death of Yueyue in particular, have provoked much public outrage and a nationwide discussion about morality in today's China. From Shanghai, someone with the cybername 60sunsetred wrote: "The Chinese people have arrived at their most morality-free moment!" There was plenty of condemnation of the cold-heartedness of the passersby. But, astonishingly, a large percentage of posters said they understood why the onlookers did not lend a helping hand. Some admitted they would do the same – for fear of getting into trouble and fear of facing another "Nanjing judge".

Let me explain the story of the muddle-headed Nanjing judge. In 2006, in the capital of Jiangsu province, a young man named Peng Yu helped an old woman who had fallen on the street and took her to a hospital and waited to see if the old woman was all right. Later, however, the woman and her family accused Peng of causing her fall. A judge decided in favour of the woman, based on the assumption that "Peng must be at fault. Otherwise why would he want to help?", saying that Peng acted against "common sense". The outcry from the public in support of Peng forced the court to adjust its verdict and resulted in Peng paying 10% of the costs instead of the total. Since that incident Peng has become a national cautionary tale: the Good Samaritan being framed by the beneficiary of their compassion.

It's true that in China you can get into trouble when you try to help. Weeks ago I spotted an accident on the fourth ring road in Beijing as I returned home one night. A man was hit by a "black car", an "illegal taxi", and his face was all bloody. Watched over by a crowd, the injured man behaved aggressively towards the driver. I got off my scooter. As I tried to pull the two men apart, I was struck myself. When I asked if anyone had reported this to the police, the driver said no. I couldn't believe that people just stared as if enjoying a free show, without doing anything. I called the helpline and the policemen turned up soon after.

The fundamental problem, in my view, lies in one word that describes a state of mind: shaoguanxianshi, meaning don't get involved if it's not your business. In our culture, there's a lack of willingness to show compassion to strangers. We are brought up to show kindness to people in our network of guanxi, family and friends and business associates, but not particularly to strangers, especially if such kindness may potentially damage your interest.

Fei Xiaotong, China's first sociologist, described Chinese people's moral and ethical characteristics in his book, From the Soil, in the middle of the last century. He pointed out that selfishness is the most serious shortcoming of the Chinese. "When we think of selfishness, we think of the proverb 'Each person should sweep the snow from his own doorsteps and should not fret about the frost on his neighbour's roof,'" wrote Fei. He offered the example of how the Chinese of that period threw rubbish out of their windows without the slightest public concern. Things are much the same today.

Under Mao, citizens were forced to behave themselves in both public and private spheres. Every March, people were obliged to go into the street to do good deeds: cleaning buses, fixing bicycles and offering haircuts. Now relaxed social control and commercialisation over the past three decades have led people to behave more selfishly again.

People are enjoying, and sometimes abusing, the vast personal freedoms that didn't exist before. To start with, it is now safe to be "naughty". Back in the early 1980s, when I worked at a rocket factory in Nanjing, one of my colleagues, a married man, was caught having an affair with an unmarried woman. He was given a three-year sentence in a labour camp and the girl was disgraced. In today's society, having extramarital affairs or keeping an ernai – second wife or concubine – is as common as "cow hair", as the Chinese would say. For a novel I am writing on prostitution, I have interviewed many prostitutes and ernai. Many see their profession as a way to gather wealth quickly, feeling few moral qualms.

China's moral crisis doesn't just manifest itself in personal life but also in business practice and many other areas. The high-profile "poisoned milk powder" case and the scandal of using "gutter oil" as cooking oil have shocked and disgusted people around the world. Last year an article, "Why have Chinese lost their sense of morality?", in which the author tried to find an explanation, was widely read. He reasoned that China has introduced the concept of a market economy from the west but failed to import the corresponding ethics, while the traditional moral principles of China no longer fit the market economy model.

There's a lot of sense in that. I believe that the lack of a value system is also deepening the moral crisis. Before Mao, the indifference towards others once so accurately described by Fei existed but was mitigated by a traditional moral and religious system. That system was then almost destroyed by the communists, especially during the 10 mad years of the Cultural Revolution from 1966 to 1976. Nowadays communism, the ideology that dominated Chinese people's lives like a religion, has also more or less collapsed. As a result, there's a spiritual vacuum that cannot be filled by the mere opportunity of money-making.

To drag China out of its moral crisis will be a long battle. The pressing question is how to make people act in cases of emergency and the solution is law. After the "Nanjing case", there have been discussions about introducing a law that imposes a "duty of rescue" as exists in many European countries. I am all for it, because that's probably the only way to propel action for a people who do not see a moral obligation in rescuing others.

The Yueyue incident revealed an ugly side of China. I hope the entire nation will take the opportunity to take a hard look at ourselves and ask ourselves what's wrong with society. There's at least hope in the action of the rubbish collector who rushed to Yueyue's side without hesitation.

China's economy is galloping like a horse without a rein and its position in the world is rising. We Chinese have every reason to feel proud about what we've achieved. Now we demand respect. But how can we possibly win respect and play the role of a world leader if this is a nation with 1.4 billion cold hearts?