Just before a no-confidence motion in parliament, K. P. Sharma Oli resigned as Nepal's prime minister on July 24, 2016

Nepal's K.P. Sharma Oli resigned as prime minister on Sunday, minutes before facing a no-confidence motion in parliament he was certain to lose, plunging the impoverished, quake-hit nation into fresh turmoil.

Oli was forced to quit after former Maoist rebels deserted his fractious, ruling coalition, accusing him of reneging on past deals and following deadly unrest over a divisive new constitution.

"I have decided to open the road to elect a new prime minister in this parliament and presented my resignation to the president," Oli, who has only been in power for nine months, told lawmakers ahead of the no-confidence vote.

Nepal's president is now expected to ask political parties to try to form a new power-sharing government and nominate a consensus candidate for prime minister.

Maoist chief Pushpa Kamal Dahal could become the new premier after the former rebels and main opposition Nepali Congress party said before the vote that they would try to form a new administration if Oli lost.

A letter from the president's office read out in parliament said the current cabinet would continue until a new government was formed, a process expected to take at least a week.

Dahal, the country's first prime minister after the Maoist insurgency ended in 2006, pulled his party from Oli's coalition two weeks ago, leaving it without a majority.

In his speech, the embattled premier accused the Maoists of undermining his government, which he said was working to rebuild the Himalayan country after a devastating earthquake last year.

"I am concerned that the steps taken were driven by selfishness and revenge (and they) will cause a long-term negative impact and push the country to instability," he said of the motion, during the nearly two-hour speech.

Oli's resignation is the latest crisis to hit Nepal which has suffered from years of political instability and struggled to get back on its feet since last April's quake that claimed almost 9,000 lives.

- Coalition cracks -

The Maoists joined Oli's government last October, weeks after Nepal adopted the new national constitution.

Oli has faced fierce criticism over his handling of protests against the constitution, which triggered a months-long border blockade in southern Nepal by demonstrators from the Madhesi ethnic minority.

More than 50 people died in clashes between police and protesters, who said the constitution left them politically marginalised.

Kathmandu accused New Delhi of imposing an "unofficial blockade" on the landlocked nation in support of the Madhesis, who share close cultural and family links with Indians across the border.

Cracks began to appear in Oli's coalition two months ago when the Maoists threatened to topple him, prompting the premier to draw up an 11th-hour deal with Dahal.

But Dahal later withdrew from the coalition, citing the government's failure to implement that agreement to withdraw war cases from Nepal's courts and offer amnesties to people accused of abuses during the decade-long Maoist conflict.

Dahal, better known by his nom-de-guerre Prachanda, painted Oli as an egocentric who refused to listen to the people and demanded that he resign.

After debate on the no-confidence motion kicked off on Friday, two smaller parties also abandoned the coalition, leaving Oli's Communist Party of Nepal (Unified Marxist Leninist) floundering for support.

The new constitution, the first drawn up by elected representatives, was meant to cement peace and bolster Nepal's transformation to a democratic republic after decades of political instability.

But ongoing discussions between the government and protesters over the charter have failed to yield agreement.