KATHMANDU, Nepal - The world's last Hindu kingdom became its newest secular republic yesterday as Nepal's lawmakers, led by former communist insurgents, abolished the monarchy that had reigned over this Himalayan land for 239 years.

Throughout the day, thousands of people marched, danced and sang in the streets of Kathmandu in anticipation of the vote, waving red hammer-and-sickle flags as dour King Gyanendra awaited his fate in the pink concrete palace that dominates the city's center.

He finally found out the fate of his throne late in the day when, as expected, the newly elected Constituent Assembly declared the country a republic and abolished the monarchy by a vote of 560-4. The assembly's 37 other members were not present.

"We have entered a new era today," said Prime Minister Girija Prasad Koirala, calling Nepal's rebirth as a republic "the dream of the whole nation."

There was no immediate reaction from the king, 61, who has remained silent in recent months as it became apparent that his days on the throne were numbered. He has 15 days to quit the 1970s-era palace and move to his large private residence in the city or face the possibility of being removed by force.

As word of the republic's declaration spread through Nepal's capital, Kathmandu, groups of young men yelled in the streets and set off firecrackers to celebrate the end of a dynasty that dates to 1769, when a regional ruler conquered Kathmandu and united Nepal.

"The people in Nepal have defeated the autocrat Gyanendra," said Gopal Thapa, 23, a supporter of the Maoists, the former rebels. "Nepal is now the people's republic."

Not since the shah of Iran was deposed in the bloody 1979 Islamic revolution has one of the world's monarchs been forced from his throne.

But while the end of Nepal's royal dynasty may have come in a peaceful vote, the stage for the monarchy's demise was set by a communist insurgency that bled Nepal for a decade, and a 2001 palace massacre in which a gunman, allegedly the crown prince, assassinated King Birendra and much of the royal family before killing himself.

Gyanendra then assumed the throne. But the killings helped pierce the mystique surrounding a line of kings once revered as reincarnations of the Hindu god Vishnu. His 2005 seizure of power from a civilian government only made matters worse. He said he needed total authority to crush the Maoists, but he quickly began locking up peaceful opponents and found himself beset by an intensifying insurgency.

A year later, weeks of huge protests forced Gyanendra to restore democracy, after which the Maoists came out of the bush and began peace talks. An interim government, meanwhile, slowly stripped away the trappings of a kingdom. Then came April's vote for the assembly, sealing the fate of the kingdom.

With the king now gone, Nepalis are settling in for a three-day holiday. But what comes next remains uncertain. While the Maoists say they are committed capitalists and have no intention of nationalizing industries or setting up collective farms, they have promised sweeping change in this largely impoverished country.

But they are struggling to form a government - yesterday's opening assembly session was delayed for hours while they wrangled with other political parties over who should be president and what powers he should have. At the end of the day, they still did not have a deal.

Nepal also is regularly bloodied by political violence, as evidenced by a string of small bombings this week. They caused no serious injuries but underscored how difficult it will be to fashion lasting peace.