KATHMANDU (Reuters) - Nepals parliament elected a moderate communist leader as the new prime minister on Saturday, hours after two people were killed in an explosion that ripped through a church near the capital. Three weeks ago, Maoist Prime Minister Prachanda resigned, plunging the nascent republic into a crisis sparked by his failure to fire the army chief. Madhav Kumar Nepal, 56, a veteran leader of the moderate Communist UML party, was elected unopposed after the Maoists refused to field a candidate and said they would boycott the vote. Since there is only one proposal to elect Madhav Kumar Nepal as prime minister, I declare him elected unopposed, said Subas Nemwang, the parliaments speaker, as the Maoists stormed out of the legislature. The former Maoist rebel leader Pushpa Kamal Dahal, who still uses his nom de guerre Prachanda, meaning fierce, resigned on May 4 after President Ram Baran Yadav stopped him from firing General Rookmangud Katawal. Prachanda accused Katawal of undermining the civilian government. A loose alliance of 22 political parties later backed the moderate communist Nepal for the post of prime minister. A former bank clerk turned politician and a commerce graduate, he is known for his ability to negotiate with rivals. The new government has a year to oversee the drafting of a new constitution, a key part of the deal that ended a conflict with Maoist insurgents that killed more than 13,000 people. Hours before the election, a crude bomb ripped through a church near Kathmandu, killing two people and injuring 12 others, highlighting continuing security concerns. The blast hit the Dhobighat suburb in Lalitpur, an adjoining town 4 km (3 miles) south of Kathmandu. The wounded people have been rushed to a local hospital and we are investigating, superintendent of police Kedarman Singh Bhandari said. Police cordoned off the area, which was strewn with shattered window panes. There was no claim of responsibility but a little-known Hindu group, the Nepal Defence Army, threw pamphlets around the site demanding Nepal be declared a Hindu state. Nepal became a secular state three years ago after the decade-long civil war ended.