He was elected as the country's first president in 2008 following the abolition of a 240-year-old Hindu monarchy.

"I announce that Bidhya Devi Bhandari has been elected to the post of Nepal's president," said Speaker Onsari Gharti Magar, to loud cheers from parliamentarians.

Scores of supporters waited for Bhandari outside parliament, applauding as she thanked lawmakers for electing her.

"I will do my best to protect the constitution and work for the country's development and prosperity," she told reporters.

Bhandari, a rare female face in Nepal's parliament, took up politics in her teens, seeking to overturn the absolute monarchy and later marrying a fellow communist, Madan Bhandari.

But it was after her husband's death in a vehicle accident in 1993 that the mother of two became a prominent voice, riding a wave of sympathy to win a seat in parliament.

Bhandari, who served as defense minister from 2009 to 2011, was hailed by campaigners for her strong stance in favor of increasing female representation in parliament to 33 percent.

But she earned the anger of rights activists when she supported a provision in the new charter that bars Nepali single mothers and women married to foreigners from passing on citizenship to their children.

"Some may say she is not the most feminist person to become president," said Guna Raj Luitel, editor of Nepali newspaper Nagarik Daily.

"But she is a single woman in a male-dominated society who has made such progress in politics and that is quite commendable," he said.

Bhandari's predecessor Yadav was initially supposed to hold office for only two years. But years of political wrangling delayed agreement on a new constitution, which was only finally adopted last month.

Women in power

Bhandari, 54, is the second woman to be elected to a senior position since the new charter, after Magar became the country's first female Speaker earlier this month.

As required by the constitution, parliament this month also elected a new prime minister, KP Sharma Oli, who faces the tough task of unifying the earthquake-hit country as ethnic tensions flare.

The constitution, the first drawn up by elected representatives, was meant to bolster peace and ease Nepal's transformation to a democratic republic after decades of political instability and a 10-year Maoist insurgency.

But it has instead sparked deadly violence.

More than 40 people have been killed in clashes between police and ethnic minority protesters, who say a new federal structure laid out in the charter will leave them under-represented in parliament.

Work on the constitution began in 2008 after Maoist rebels laid down arms and entered politics, winning parliamentary elections and abolishing the monarchy. But power-sharing squabbles between parties stymied progress.

Lawmakers finally reached agreement in June, spurred by the massive earthquake two months earlier that killed nearly 8,900 people and left more than half a million people homeless.