Former general Michel Aoun has won a parliamentary vote to become president of Lebanon. Aoun's name was indicated in a majority of 83 ballots in the second round of voting, after falling two votes short of a majority in the first.
The second round of voting, where a majority of 65 was needed to win, had to be repeated several times due to irregularities with the distribution of ballots. MPs were made to walk to the ballot box instead of passing it around, to prevent double voting.
Those opposing Aoun either submitted a blank paper or came up with alternative candidates, such as pop star Myriam Klink or fictional character Zorba the Greek.
The 81-year-old Aoun had to win support of conflicting parties to end the 29-month long political deadlock that saw 45 voting sessions failing to elect a new president.
After winning support from Hezbollah in December 2015, the crucial endorsement came from former Prime Minister Saad Hariri, a Sunni Arab close to the Saudi regime, who is a fierce critic of Hezbollah.
In a speech on 20 October, Hariri said supporting Aoun was necessary to "protect Lebanon, protect the [political] system, protect the state and protect the Lebanese people". But there is speculation that Hariri struck a deal with Aoun that will see the former appointed prime minister, a post he held between 2009 and 2011.
Ahead of the vote, the capital Beirut was filled with banners and pictures of Aoun describing him as a"strong president". The streets were filled with soldiers and military vehicles and military helicopters circles in the skies above.
The Syrian ambassador to Lebanon, Ali Abdul Karim, attended the vote, which was seen as key in determining future relations between the two neighbouring countries. Aoun had staunchly opposed Syria's 30-year occupation of Lebanon, even while he was in exile in France.
But once the Syrian troops left the country in 2005 and he returned, he struck an alliance with Hezbollah, a long-time supporter of the Damascus regime. Aoun defended the party's support for Syrian President Bashar al-Assad, saying it protected Lebanon and Lebanese Christians from the threat of jihadist militancy.
Lebanon's presidency has been vacant since May 2014, when Michel Suleiman's term expired. The parliamentary deadlock over the election of the new president raised concern over the political stability of the country, aggravated by violent rallies protesting the government's inability to solve a garbage crisis.
Aoun supporters have organised celebrations in different Lebanese regions, including downtown Beirut. Other protesters challenging the legitimacy of the Lebanese parliament, as well as the result of the presidential elections, are also expected to gather.
Aoun fought two wars in the late 1980s at the end of Lebanon's 1975-90 civil war, one against Syria and another against rival Christian forces. This will be the first time a former civil war combatant will hold a position of power in Lebanon.
The presidential post is largely ceremonial, but according to the sectarian political agreement, it is reserved to a Maronite Christian, whereas the prime minister is a Sunni Muslim and the speaker of parliament a Shia Muslim.