Kathmandu, Nepal (CNN) -- Nepal averted a political and constitutional crisis Saturday morning with the tenure of the constituent assembly and parliament extended an hour after it expired.
The opposition Maoists agreed to support an amendment to an interim constitution to extend the tenure of the assembly, which also acts as the parliament, by a year.
"There has been an agreement in principle that the prime minister will resign within a few days once the incomplete issues of the peace process are dealt with and the constitution's drafting is assured," Arjun Narsingh KC, a Nepali Congress spokesman, said to journalists after daylong negotiations among the three major parties.
Prime Minister Madhav Kumar Nepal will resign after the future of the 19,602 United Nations-verified Maoist combatants is determined and there is a guarantee that a new constitution will be promulgated in a year.
"The prime minister's resignation could be in two days or five days, depending on when the agreement is there on the two issues," KC said.
The agreement was reached after a day of negotiations among the Nepali Congress; Prime Minister Nepal's Communist Party of Nepal (Unified Marxist-Leninist); and the opposition Unified Communist Party of Nepal (Maoist), better known as the Maoists.
The Maoists, former rebels who signed a peace deal in 2006, had been demanding the prime minister's resignation in return for their support in extending the government's proposal for the amendment of the present interim constitution to extend the constituent assembly's tenure by a year.
The Maoists became the biggest party after elections in April 2008 but didn't have a majority in parliament.
Nepal became a republic after the elections, ending centuries of monarchy. To end it, the Maoists fought a 10-year revolt in which more than 13,000 people died.
The Maoists have said that they should lead a national government since they are the biggest party in parliament. Pushpa Kamal Dahal "Prachanda," chairman of the Unified Communist Party of Nepal, became prime minister in August 2008 but resigned in April 2009 over the sacking of the chief of army staff.
Madhav Kumar Nepal became prime minister in May of last year with the support of 22 of the 25 parties represented in parliament.
Besides the integration of the 19,602 Maoist combatants, the content of the new constitution is a contentious issue between the Maoists and the other parties.
The Maoists had called an indefinite general strike at the beginning of May to press the government to resign but called it off after six days following public pressure.
There had been intense negotiations for the last three weeks to end the political deadlock, with the Maoists demanding the prime minister's resignation and the governing coalition asking the Maoists to determine the number of combatants to be integrated into the security structure first.
With a constitutional crisis looming, the parties finally reached an agreement less than an hour before a midnight deadline.
Journalist Manesh Shrestha contributed to this report.