Gyanendra became king after the notorious 2001 palace massacre

Under the deal, Nepal will be declared a republic after a general election has been held next year and a new constituent assembly established.

The Maoists pulled out of the government in September, demanding an immediate end to the monarchy.

The latest deal was signed by Nepal's main parties, including the Maoists.

But no date has been set for the ex-rebels to rejoin the government.

Milestone

The six-party ruling alliance and the Maoists said in a statement: "Nepal will be a federal democratic republic nation and the decision will be implemented after the first meeting of the constituent assembly."

The Maoists have not stopped using violence from time to time

Elections for the new 601-member assembly are due to be held in April.

The BBC's Nepal correspondent Charles Haviland says that, while a milestone, the move is no surprise.

The Maoists walked out of the government three months ago, vowing not to return unless the royal system was scrapped.

They have now secured what they wanted, even though the other parties in the ruling coalition had said, up to now, that voters should decide on the issue via the new assembly, our correspondent adds.

Analysts say that many Nepalis will be happy to have a republic.

Unpopular monarchy

The monarchy's popularity has sunk since the death of the well-loved King Birendra in a notorious palace massacre of 2001.

Efforts by his brother, Gyanendra, to tackle the Maoist insurgency led to a worsening of the country's human rights situation.

Analysts say the king lost popular support after his decision in 2005 to sack the government and assume absolute power - only to back down after huge protests.

The Maoists called a ceasefire after the king ended his controversial direct rule in April 2006 and restored parliament.

Political parties - who were then in opposition and are now in government - had promised to work with the Maoists as a prelude to bringing them into government.

The political crisis came amid a rise in ethnic and religious tension, as regional groups strove to assert their authority in advance of the elections.

More than 13,000 people died during Nepal's decade-long insurgency, many of them civilians caught in cross-fire with security forces.