Politicians in Nepal reached a last-minute agreement Sunday to extend the Constituent Assembly's term so it can complete its long-due task of drafting a new constitution, averting a political crisis in the Himalayan nation.

Speaker Subash Nemwang announced that a government proposal to extend the assembly's term by three months had received more than the two-thirds votes required in the 601-seat assembly.

The assembly's term expired at midnight Saturday, but the speaker managed to begin the renewal process minutes before that, and leaders of the three main political parties reached an agreement during the early hours of Sunday.

The drafting of a new constitution is a key part of a peace process that began in 2006 after the former Maoist rebels gave up their armed revolt and joined mainstream politics. The Maoists are now the largest political party in Nepal.

Laxman Ghimire of the Nepali Congress, the main opposition party, said the parties agreed that a first draft of a new constitution would be finished during the three-month extension, and that the entire peace process would be completed.

It was also agreed that Prime Minister Jhalnath Khanal would eventually step down and be replaced by a national government that would have representation from all the political parties in parliament.

The Constitutional Assembly also currently serves as the country's legislature.

The assembly has not been able to complete its main task of writing a new constitution because of disagreements and power struggles between the main political parties.

Since the assembly was first elected in 2008 to write a new constitution aimed at cementing the peace and bringing Nepal from a monarchy to a republic, the country has produced three different governments and no constitution.

Some of the disagreements center on whether to divide the country in a federal system based on ethnic groups or strictly by geography. But the parties squabble mostly over who gets to lead the country.

When the Constitutional Assembly's two-year term was about to expire last May, a last-minute deal was reached, with the opposition parties agreeing to extend the deadline for a year in return for the government's resignation.