Prime Minister Atal Bihari Vajpayee, the Hindu nationalist leader who presided over an economic boom in India, its emergence as a declared nuclear power and a widely applauded peace initiative with Pakistan, resigned Thursday night after a secular opposition alliance led by the Congress party scored a stunning upset in parliamentary elections.

Although a new government has not been formed, Congress party officials said Vajpayee is likely to be succeeded as prime minister by party leader Sonia Gandhi, the Italian-born widow of former prime minister Rajiv Gandhi and the head of modern India's most famous political dynasty.

The counting of results Thursday from elections that were spread over the past three weeks brought a dramatic and unexpected reversal for Vajpayee, 79, and his Bharatiya Janata Party (BJP), which leads the coalition that has governed India since 1998.

Only a few weeks ago, pollsters had predicted that the ruling coalition would coast to victory on the strength of India's recent economic growth, Vajpayee's personal appeal and his popular moves toward peace with Pakistan.

But if the government's campaign theme of "India Shining" played well with the growing -- and predominantly urban -- middle class, it apparently failed to resonate in the impoverished rural villages where most of India's billion-plus people still live.

With the count nearing completion Thursday night, official results showed that Congress and its allies would easily surpass the 272 seats required for a majority in the Indian Parliament's lower house, the Lok Sabha, and that Congress would occupy more seats than the BJP for the first time since 1996.

"When you gave us the mandate last time, stability, good governance and development were the challenges facing the nation," a somber, reflective Vajpayee said in a brief televised address Thursday night. "It is for you and history to judge what we have achieved during this period."

He added, "My party and alliance may have lost, but India has won."

Vajpayee's concession speech signaled a remarkable turnaround for the Congress party, which led India for almost half a century after independence from Britain in 1947 but in recent years had lost ground to the BJP. For much of its history, Congress was led by Jawaharlal Nehru, India's first prime minister, and his descendants. Nehru's daughter, Indira Gandhi, served twice as prime minister and was assassinated in 1984. She was succeeded by her son, Rajiv, who was assassinated in 1991, two years after losing the office.

At a news conference Thursday night, Sonia Gandhi emphasized her party's secular credentials -- an implicit contrast with the BJP, whose leaders have often been accused of sowing enmity between Hindus and India's large Muslim minority.

But she also pledged to continue Vajpayee's peace effort, which began last year and has blossomed into regular high-level contacts between two nuclear-armed rivals that nearly fought their fourth war in 2002.

"From the beginning, we've been supporting Vajpayee's initiative with Pakistan," Gandhi said. "We said dialogue must be initiated with Pakistan. There is no question of us not following in that policy."

Some analysts questioned whether Gandhi would enjoy the same latitude as Vajpayee in negotiations with Pakistan over the divided Himalayan region of Kashmir. "It's going to be very difficult for Sonia Gandhi, as a foreigner, to make concessions to Pakistan over Kashmir," said Prem Shankar Jha, a columnist for Outlook magazine.

The prospect of a government led by the Congress party and its allies also is likely to cause some apprehension in Washington. The Bush administration enjoyed warm relations with Vajpayee's government, with which it shared common views on economic policy and the need to confront Islamic extremism. Congress party leaders have been critical of the BJP's closeness to Washington and have said its economic reforms have hurt the poor.

Congress party officials said the new coalition, which includes communists, would likely move more slowly than the BJP-led government on privatization of state-owned industries, although they noted that it was a Congress government that launched India's economic liberalization in 1991.

"We will accelerate reforms, but we will pursue disinvestments with safeguards," party spokesman Abhishekh Singhvi said in an interview. "We will not disinvest just for the sake of selling and raising money, but to get rid of inefficiency and losses. Our big focus will be on employment and agriculture."

On foreign policy, Singhvi said that while "it is important to maintain continuity," the party favored a return to "the doctrine of nonalignment" that defined Indian foreign policy during the Cold War. "The doctrine is all the more important in a . . . world where one country is a supercop," he said. "Will we advocate becoming a part of the U.S. bloc? Obviously not. We are open to trade but will not fall at somebody's feet."

Vajpayee's party rose to prominence in the early 1990s as the embodiment of a philosophy of cultural nationalism known as Hindutva -- literally, Hinduness. Soon after coming to power in 1998, Vajpayee and the BJP-led government cemented their nationalist credentials by detonating a nuclear device, prompting Pakistan to do the same. BJP politicians, though not Vajpayee himself, were subsequently accused of fomenting anti-Muslim violence in the state of Gujarat in 2002.

Despite the party's links to Hindu extremists, Vajpayee has cultivated a moderate image that has only been enhanced by his peace overtures to Pakistan. That, coupled with his gentle demeanor and dry sense of humor, won him broad support in India, especially among young people. The pragmatic demands of coalition politics, meanwhile, spurred the BJP to soften its emphasis on Hindu nationalism.

In state elections last fall, the BJP decided to stress development issues over cultural themes. The results were so positive that the government decided to call early national elections, which began on April 20.

Going into the parliamentary contests, BJP strategists sought to capitalize on Vajpayee's popularity as well as what they called the "feel-good factor," which was symbolized by India's success in attracting service jobs outsourced from the United States and other developed countries. Congress and its allies, meanwhile, emphasized the continuing poverty in the countryside as well as the dislocations wrought by globalization and economic reform; one campaign ad featured youths staring disconsolately at a locked factory gate.

In the end, it was that bleak message that resonated with voters.

"The ground reality and the results have called the bluff of the artificial atmosphere of feel-good that the NDA had created," Ahmed Patel, Gandhi's political secretary, told reporters. Patel was referring to the National Democratic Alliance, the formal name of the BJP-led coalition.

Although exit polls had indicated a tightening race in recent days, BJP officials acknowledged that they were totally unprepared for the outcome. "There was an invisible undercurrent in the Indian electorate against the NDA that none of us could gauge," Sushma Swaraj, a minister in Vajpayee's government, told reporters at the BJP headquarters this afternoon. "The results are totally against our expectations. We will have to sit in the opposition."

Swaraj added, however, that the election results were "not a verdict for Sonia Gandhi to become prime minister either. . . . We should not conclude that people of India have accepted a foreigner as prime minister. My mind still does not accept Sonia Gandhi as the prime minister."

Special correspondent Rama Lakshmi contributed to this report.

Sonia Gandhi, leader of India's Congress party, is likely to become prime minister. Congress party supporters celebrate in New Delhi after learning results of parliamentary races, which could return the Gandhi family to power.