|Jhalanath Khanal gained Maoist support at the last minute and was elected prime minister [AFP]
Politicians in Nepal have elected a new prime minister, effectively ending a seven-month leadership vacuum in the country.
Jhalanath Khanal, the chairman of the UML (Unified Marxist Leninist) party won the vote on Thursday, after securing the support of the Maoists, the largest force in the 601-member parliament.
His election breaks a long deadlock that has seen the country without a government since June, with political leaders unable to reach agreement on the formation of a new administration in 16 previous rounds of voting.
"Jhalanath Khanal secured 368 votes, giving him a majority," Subash Chandra Nemwang, the speaker, told parliament.
"I therefore declare him the winner of the election and the new prime minister."
State television showed Khanal, decked in ceremonial marigold garlands, leave parliament immediately after the vote without speaking to the media.
Addressing parliament before the election, he said it was crucial for political leaders to consolidate the substantial progress made since the civil war between Maoist fighters and the state ended in 2006.
"We must move ahead very quickly or once again be plunged into crisis," he said.
"Parliament's main task is to draft the new national constitution and I can assure you that we will achieve that under my party's leadership of the next government."
Khanal only secured the support of the Maoist party at the last miniute, after their leader Pushpa Kamal Dahal, better known as Prachanda, agreed to pull out of the race.
It is not yet clear what form the new government will take, although it is likely to include former fighters.
Khanal has said repeatedly that the Maoists must be involved in any future government if the peace process that began when the war ended is to succeed.
The Maoists formed a coalition government with the UML after winning 2008 elections and abolishing the country's 240-year-old Hindu monarchy. But Prachanda resigned as prime minister less than a year later in a row with the then head of the army.
In May 2009, the UML formed an alliance with the centrist Nepali Congress, the second-largest party in parliament, but their coalition government fell last June under intense pressure from the Maoists.
Since then Nepal has been led by a caretaker administration with only limited constitutional powers, delaying much-needed government spending in the desperately poor country.
"We decided that we would have to make this sacrifice in order to end the political deadlock," said Prachanda, as he announced his decision to withdraw from the election.
"In order to comply with the people's wish that a new government be formed and a constitution drafted, we have decided to support Jhalanath Khanal."