Thousands of Nepalis cheered the declaration of the republic
The Himalayan nation of Nepal has become the world's newest republic, ending 240 years of monarchy.
A constituent assembly meeting in the capital, Kathmandu, overwhelmingly voted to abolish royal rule.
The Maoists, the largest party after laying down arms and standing in last month's elections, were committed to ousting King Gyanendra.
People celebrated wildly in the streets of the capital after news of the assembly vote.
The approved proposal states that Nepal is "an independent, indivisible, sovereign, secular and an inclusive democratic republic nation".
Only four members of the 601-seat assembly opposed the change.
Royal privileges "will automatically come to an end", the declaration says.
It also states that the king's main palace must be vacated within a fortnight, to be transformed into a museum.
"I am overjoyed," student Rajesh Subedi, 21, told AFP news agency as Kathmandu celebrated.
"This is the most important day of my life."
The BBC's Charles Haviland in Kathmandu says it is not clear how soon King Gyanendra will leave.
The Maoists and other politicians are being conciliatory about the monarch now being ousted and say he should live on in Nepal as a private citizen.
In the run-up to the vote, suspected royalists threw three small bombs in the capital.
One exploded at an open-air theatre in Kathmandu on Wednesday evening, injuring one person. Another went off outside the assembly venue but no-one was hurt.
People celebrating and marching on streets of Kathmandu
On Tuesday, another two explosive devices were left in a park, but police said only one exploded, slightly injuring two people.
Some militant pro-Hindu and pro-royal factions are campaigning violently against Nepal's shedding of its royal - and its officially Hindu - status.
The assembly was given the initial task of rubber-stamping the abolition of the monarchy.
But the vote was delayed by 12 hours, while the Maoists and the other main parties settled differences about distribution of power between the president and the prime minister in an interim period.
The government of the new Nepalese republic is expected to be led by the Maoists, who only entered politics in 2006 after signing a peace agreement that ended a decade-long insurgency.
The assembly has two years to come up with permanent arrangements for a new constitution.
The monarchy's fall from grace has come swiftly and was heralded by the 2001 massacre in which the then-Crown Prince Dipendra killed his family and several other royals, our correspondent says.