Michel Aoun, a former general, was selected as president by Lebanon’s parliament. The country had been without a president for more than two years because of factional squabbling. (Anwar Amro/AFP/Getty Images)

Lebanon’s parliament ended a more than two-year leadership vacuum Monday, electing as president a former general supported by Hezbollah in a move that gives the powerful Iranian-backed militia even wider clout in Lebanese affairs.

The selection of Michel Aoun, a Maronite Christian, highlights the complex alliances among Lebanon’s various factions as the country struggles with the humanitarian and political fallout from the Syrian civil war next door.

Aoun, 81, is a divisive figure who rose to prominence as a military leader during Lebanon’s devastating 15-year civil war, which ended in 1990. In that conflict, he fought then-occupying Syrian troops and fled to France. He returned to Lebanon in 2005, only to stun observers by befriending the Syrian leadership and its Shiite ally, Hezbollah.

[Persian Gulf Arab states declare Hezbollah a terrorist group]

Hezbollah has become the dominant player in Lebanon, angering many Lebanese by dispatching fighters to aid President Bashar al-Assad’s forces in Syria without receiving permission from Lebanon’s government. Aoun’s rise to the presidency could put Lebanon at odds with its Western and Arab allies that have sided with Assad’s opponents.

Lebanese celebrate the election of Michel Aoun (portrait) in downtown Beirut on Oct. 31. (AFP/Getty Images)

Meanwhile, more than 1 million Syrians have crossed the border into Lebanon to escape the more than five-year conflict, further straining the country’s economy and combustible sectarian politics.

In a speech after his election, Aoun addressed the issue of Syrian war refugees, who are mostly Sunni Muslims, saying that no “solution should be made in Syria that does not include” their return from Lebanon.

Many Lebanese hope that Aoun will help bring badly needed stability to their country of more than 4 million people.

The presidency — which has limited direct powers but confers the title of head of state — had been vacant since May 2014 because of factional squabbling. Meanwhile, corruption has burgeoned, a budget has not been passed in years, and seemingly simple public services, such as trash collection and electricity production, have deteriorated because of dysfunctional governance and feuding religious groups. These include more than a dozen sects of Muslims and Christians.

Lebanon’s Christian minority was divided over Aoun’s selection. Some Christians believed that his political bonds with Hezbollah would offer them greater security and influence. Others backed Aoun’s rivals.

Under a long-standing power-sharing deal in Lebanon, the presidency is reserved for a Maronite Christian. The post of prime minister goes to a Sunni Muslim, and the parliament speaker is Shiite.

But it is unclear whether Aoun can navigate a political system hamstrung by the rivalry between the region’s most powerful players: Iran, which backs Syria’s Assad, and Saudi Arabia, which opposes him.

A key factor behind Monday’s vote was a surprise decision this month by Saad Hariri, a powerful Sunni politician who has long been Riyadh’s key ally in Lebanon, to drop his long-running opposition to Aoun. In exchange, Hariri is expected to return to the post of prime minister, which he held from 2009 to 2011.

Hariri’s father, Rafiq al-Hariri, a businessman who also served as prime minister, was killed in a 2005 attack that an international tribunal blamed on members of Hezbollah.

In a sign of Lebanon’s tense political balance, security was expanded across areas of central Beirut before the vote. Army helicopters crisscrossed overhead, and metal detectors were set up in the streets around parliament.

Hezbollah has launched sporadic rocket attacks from Lebanon against Israel over the years. In 2006, it fought a one-month war against Israel and managed to avoid defeat, winning the group sympathy throughout the region.

But much of that support has since evaporated because of Hezbollah’s growing influence over Lebanese politics, its refusal to relinquish its arms and its involvement in the Syrian civil war.

Brian Murphy in Washington contributed to this report.

Read more:

Decade after last Lebanon war, Israel warns next could be bigger

Hezbollah blames commander’s death on Sunni extremists

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news