Lebanon`s dueling political factions have reached a breakthrough deal ending an 18-month political crisis that almost pushed the country to brink of a new civil war, an official told CNN Wednesday.

The Western-backed parliamentary majority and the Syrian-backed opposition agreed on the formation of a national unity government, said Ali Hamdan, advisor to Lebanese House Speaker Nabih Berri.

The agreement hands the opposition veto power. That key demand was the sticking point in the political stalemate.

The two sides also agreed on an electoral law, which should lead to parliament`s election of a president.

A president will be selected in the next two days, Hamdan said.

The deal was struck after five days of intense talks in the Gulf state of Qatar. The talks were organized by Qatar`s emir and prime minister.

Lebanon`s presidency has been vacant since pro-Syrian President Emile Lahoud`s term ended late last year.

Despite general agreement that army chief Gen. Michel Suleiman should fill the post, political wrangling among Lebanon`s political factions -- including disagreements on how to share power in a future Cabinet -- had kept the issue from coming up for a vote.

Last week, the Syrian-backed Shiite Muslim militia Hezbollah said it would end a civil disobedience campaign if the outcome of the Qatar meeting was positive.

They made the announcement after the worst outbreak of internal strife to hit Lebanon since the end of its civil war in 1991.

The clashes began after a labor protest, launched on May 2, and escalated into a flashpoint over the political crisis. At least 62 people were killed.