The fall of the Indian government is a huge political shock that strikingly echoes the only comparable electoral upset, the defeat of Indira Gandhi in 1977. Then as now, just about the entire commentariat was convinced that the incumbent would win; then as now, the opposition was widely written off; then as now, India's voters left the politicians and media with egg on their faces. Both elections are high points in the history of Indian democracy. An ornery electorate that doesn't do what it's supposed to do is a fine and cheering thing.

In the 21/2 years before the 1977 election, Gandhi's autocratic "emergency" regime, initiated after she was found guilty of electoral malpractice in 1975, had been guilty of many civil and human rights abuses, including forced sterilizations and vasectomies. The National Democratic Alliance (NDA) coalition led by Atal Bihari Vajpayee's Bharatiya Janata Party (BJP) was not by any means a dictatorship, but its leaders have turned a blind eye to some terrible deeds, notably the mass killings, mainly of Muslims, in the state of Gujarat, where the BJP-led state government itself is accused of a role in the slaughter of 2002. The Congress Party's success in Gujarat suggests that voters have been sickened by what they have seen, just as Gandhi's fall in 1977 was an expression of national disgust at her government's brutalities.

The oldest Indian rivalries of all have resurfaced in this election, as they also did in 1977. Then as now, much of the urban bourgeoisie voted for the government, while the impoverished Indian masses, in particular the rural poor, mostly voted against it. The Indian battle for centrality in the debate about the country's future has always been, to some degree, a battle between the city and the village. It is between, on the one hand, the urbanized, industrialized India favored by both the socialist-inclined Jawaharlal Nehru and the free-market architects of "India Shining," the new India in which a highly successful capitalist class has transformed the heights of the economy; and, on the other hand, the agricultural, homespun India beloved of Mahatma Gandhi, the immense countryside India where three-quarters of the population still lives and which has not benefited in the slightest from the recent economic boom.

It's no accident that the ruling alliance lost heavily in Andhra Pradesh and in Tamil Nadu, precisely the states that wooed information technology giants such as Microsoft to set up shop, turning sleepy "second cities" such as Madras, Bangalore and Hyderabad into new-tech boom towns. That's because while the rich got richer, the fortunes of the poor, such as the farmers of Andhra, declined year by year. The gulf between India's rich and poor has never looked wider than it does today, and the government has fallen into that chasm.

The failure of the NDA's ubiquitous "India Shining" slogan has backfired just as, in Indira Gandhi's hour of defeat, her grandiose slogan Garibi Hatao -- "remove poverty" -- was successfully rewritten by her opponents as Indira Hatao -- "remove Indira."

India's business elite has hastened to welcome the Congress victory, and we shall have to see how the change of government affects market confidence. But the dispossessed of India have dealt a mighty blow to the assumptions of the country's political and economic chieftains, and the lesson should be learned by all parties: Ignore the well-being of the masses at your peril.

I have two immediate wishes for the new era. The first is that the debates about "foreignness" can be laid to rest. Those of us who are part of the Indian diaspora, and who have fought for years to have Indians recognized as full citizens of the societies in which we have settled and in which our children have been born and raised, have found the attack on the Italian origins of Sonia Gandhi, the Congress Party's leader and widow of the slain prime minister Rajiv Gandhi, to be highly unpleasant. Even more unpleasant were the BJP's suggestions that her children, the children of Rajiv Gandhi, were also somehow aliens. You can't have it both ways. If Indians outside India are to be seen as "belonging" to their new homelands, then those who make India their home, as Sonia Gandhi has done for 40 years or so, must be given the same respect. Gratifyingly, the electorate has shown it just doesn't care about the "foreignness" issue. A BJP leader foolishly said in the immediate aftermath of his party's rejection that he thought it "shameful" that India might be led by a foreigner. Such slurs are part of the reason for the BJP defeat. They are essentially racist, and must cease.

My second wish is that the study of India's history can now be rescued from the extremists and ideologues. The outgoing government's politicization of historical scholarship -- its determination to impose textbooks peddling a narrow, revisionist, Hindu-nationalist vision of India's past on the country's schools and colleges, and its deriding of the work of the greatest Indian historians, such as Professor Romila Thapar -- was one of its most alarming initiatives. The BJP has often seemed to want to inflame our perceptions of the past in order to inflame the passions of the present. Congress and its allies have it in their power to restore the atmosphere of cool objectivity that true learning requires.

Delightful as it is to watch democracy on such a scale in action, one doesn't have to give the new government an unreserved welcome. Time will tell whether this new coalition will hold or disintegrate. The Congress Party will have to relearn the arts of government after the long wilderness years, and Sonia Gandhi -- who has proved she has the stomach for the fight -- will have to prove that she is not just keeping the leader's seat warm for her son or daughter to inherit, that she is a true, unifying leader.

Time will tell, too, whether the defeated BJP casts off, in opposition, the velvet glove of moderation that Vajpayee imposed during its time of power, and reinvents itself as a hard-line communalist force. If that happens the years ahead could be full of conflict and violence.

Meanwhile, we can enjoy this rare moment of hope.

The writer is a novelist and essayist. His latest book is "Step Across This Line," a collection of essays.