Kathmandu , Nepal ( CNN ) -- After more than seven months of political gridlock , Nepal 's parliament Thursday elected a 60-year-old leftist leader as the country 's new prime minister . Jhala Nath Khanal , chairman of the leftist Communist Party of Nepal ( Unified Marxist-Leninist ) , received 368 votes in the 601-member parliament . His nearest rival , Ram Chandra Poudel of the Nepali Congress , got 122 votes and Bijay Kumar Gachhedar of Madhesi People 's Rights Forum ( Democratic ) got 67 votes . Before the vote , Khanal said in parliament that resolving the political complexities of the country would be his first priority . Khanal faces the challenge of preparing -- with the support of other parties -- a new republican constitution by a May 28 deadline and finalizing an agreement on the future of nearly 20,000 Maoist combatants . The country had been without a proper government since outgoing and caretaker prime minister Madhav Kumar Nepal resigned in June . Sixteen rounds of voting in parliament since July failed to produce a prime minister since none of the parties had a majority . Nepal 's biggest party , the Unified Communist Party of Nepal ( Maoist ) , decided to withdraw its own candidate earlier Thursday and back Khanal . He becomes the third prime minister since Nepal became a republic in 2008 , ending centuries of monarchy rule . He replaces Nepal , who was also of the same party but had the support of Nepali Congress , the second biggest party in parliament . The Maoists fought a 10-year insurgency to end the monarchy and signed a peace deal in 2006 in which the combatants were to be integrated into the security forces , but the exact process of how that will be accomplished has yet to be agreed upon between the parties . The U.S. Embassy in Kathmandu congratulated the people of Nepal on the election . `` We look forward to working with incoming Prime Minister Khanal and continuing the warm and constructive relationship between the United States and Nepal , '' a statement from the embassy said . `` We are hopeful that today 's election will give renewed momentum to the peace process and constitution drafting . '' United Nations Secretary-General Ban Ki-moon also praised the election , according to a spokesman . `` He congratulates the Prime Minister-elect and reaffirms the support of the United Nations to all efforts to complete the peace process and to adopt a new constitution , '' a statement from Ban 's spokesman said . `` He believes this development will give a significant boost to efforts to fully implement their outstanding commitments under the Comprehensive Peace Accord and the interim constitution , notably the integration and rehabilitation of the Maoist combatants , democratization of the army and adoption of a new constitution . '' Earlier Thursday , Maoist leader Pushpa Kamal Dahal 'Prachanda ' withdrew his candidacy for the prime minister race , saying that his party would concentrate on the constitution and the future of the combatants . He said he realized he was not going to win and the country needed a proper government . `` There is a need for sacrifice to resolve the problems , '' Dahal said . `` The Maoists , since it is the biggest party , should take this responsibility . '' The communist leader said that if parliament could not elect a prime minister again , people would throw shoes at the politicians -- a high insult in certain cultures . There has been widespread discontent among the Nepalese about the political stalemate . Last month , prime minister-elect Khanal was slapped in the face by 52-year-old man at a political rally , who accused the politicians of being selfish . Nepal 's political crisis began when Dahal resigned as prime minister in May 2009 after the ceremonial president , who is the supreme commander of the army , reinstated the army chief Dahal had fired .
NEW : U.S. , U.N. praise the election of the prime minister . On its 17th try , Nepal 's parliament elects a new prime minister . The vote was held in an atmosphere of celebration and calm after weeks of violence that left more than 1,000 people dead. He 's the third prime minister since the end of the monarchy in 2008 .