Nepal's 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.