TALLINN, Estonia — Estonia finally has chosen a new president, who will be the Baltic country’s first woman to hold the post.

After two failed votes and weeks of heated debate, lawmakers on Monday unanimously elected European Union accountant Kersti Kaljulaid in an 81-0 vote, with 20 members absent or abstaining.

The 46-year-old Kaljulaid will succeed President Toomas Hendrik Ilves, who is stepping down next week after two five-year terms in the largely ceremonial post.

The choice of Kaljulaid, who works at the European Court of Auditors, became possible after the six parties in Parliament agreed to propose a political outsider as a single candidate.

“I believe the whole of Estonia won today. We saw that lawmakers actually did what they pledged to do,” Kaljulaid said at a news conference in veiled criticism of the prolonged election process, which many Estonians have condemned as no less than a mockery of democracy.

Monday’s election was preceded by an electoral college’s failure to choose a president from among five candidates last month. Lawmakers were unable to pick a president from among four candidates in August.

Kaljulaid, who holds a biology and business degree from the University of Tartu — Estonia’s premier educational institution — will become the tiny country’s fourth president after independence in 1991.

While the prime minister holds political power in Estonia, a nation of 1.3 million, the president is largely a ceremonial figure but acts as the supreme commander of the armed forces and can veto legislation.

A key pledge by Kaljulaid is to be a president for all the country’s citizens and she promised Monday to keep up her Russian language skills and regularly discuss issues with Estonia’s sizable ethnic Russian minority, which makes up a quarter of the population.

She will be sworn in on Oct. 10.