With the votes of the governing socialists, the Albanian parliament has elected former army chief Bajram Begaj as president.

78 out of 140 MPs voted for the 55-year-old military medic on Saturday.

There were four no votes and one abstention, as reported by the ATA news agency.

The right-wing opposition boycotted the election.

Begaj graduated in general medicine in Tirana and became a military doctor.

In the armed forces, he made it to the commander-in-chief of the medical service.

He also commanded the Command for Training and Doctrine.

He became commander-in-chief of the Albanian armed forces almost two years ago.

The Balkan country has been a member of NATO since 2009.

Begaj replaces President Ilir Meta, who was elected five years ago.

This too had been supported by the Socialists, but had fallen out with the power-conscious Prime Minister Edi Rama.

A procedure for impeachment initiated by the Socialists shortly before the end of Meta's term in office failed because the constitutional court did not consider his dismissal to be justified.

The Socialists had only nominated Begaj for the highest state office shortly before the vote on Saturday.

Three ballots had failed in the days before.

The ballot on Saturday was the first in which the 50 percent majority in parliament, which the Socialists have, was sufficient for a successful election.

Just before the election, Meta signed the document dismissing Begaj, who held the rank of major general, from the military.

The Albanian constitution prohibits military personnel from holding high public offices.

In Albania, the head of state only has protocol powers.