By Crispin Thorold
BBC News, Beirut
Public celebrations marked the the Doha deal
The negotiations have been long, tough and sometimes angry, but now Lebanon's politicians have reached an agreement on a government of national unity.
Under the terms of a deal reached in Doha in May, the share of seats was never in doubt - but over the past seven weeks the exact composition of the new cabinet often was.
Two major components of the Doha agreement have now been fulfilled.
That deal brought to an end a week of violence during which scores of people were killed, and Lebanon appeared close to a return to civil war.
Electing a new president was the easy part and it happened within days of Doha.
Both of Lebanon's political groupings agreed on the former army chief, Michel Suleiman, who is as close to a neutral public figure as you can find in Lebanon at the moment.
He will preside over the first government since November 2006 with representatives from all the major parties.
There will be 30 ministers - 16 of them from the Western-leaning parties, who back the Prime Minister, Fouad Siniora.
Eleven are supporters of what was the opposition grouping, which includes Hezbollah.
With more than a third of the cabinet seats, that party and its allies now have a veto on the major decisions of the government.
As always in Lebanon, reaching an agreement was a lengthy, tortuous process.
There were disagreements between the two major factions and also amongst the parties in each bloc.
The final ministerial line-up is a compromise in which no-one can claim a clear victory, but Hezbollah undoubtedly emerges stronger than it was before Lebanon's political standoff began.
The opposition will have significant posts - including foreign minister, deputy prime minister and the telecommunications minister.
Just one minister is from Hezbollah itself - the new labour minister.
Hezbollah nominated allies from different parties to take up its two other seats.
The government will control the finance ministry and the premiership.
Two of the most sensitive portfolios - the interior and defence ministries - will be held by appointees of the president.
This government now has the opportunity to resolve some of the enormous challenges that face Lebanon, including two major objectives.
These are "to restore confidence in political institutions and the Lebanese political system…and to promote moderation", according to Prime Minister Siniora.
Sunni muslims clashed with Alawite sect members last month
The ability of the politicians to fulfil those aims will be tested almost immediately.
Under the terms of the Lebanese constitution, the cabinet has to issue a statement within 30 days outlining its policies and programme.
Amongst the most contentious issues will be the status of Hezbollah's weapons.
The group views itself as the legitimate "resistance" to Israel.
However, many within Lebanon believe that its forces must be integrated into a national army with full control over the country.
At the moment Hezbollah is the de facto government in several parts of Lebanon, where it provides education and health services, as well as security.
The government will also have to tackle the growing sectarianism that was exposed in the fighting in May and has continued in some places since then.
In the past month there has been violence in Lebanon's second city, Tripoli, between Sunni Muslims and members of the Alawite sect.
In the past week four people have been killed there.
Much will depend on the leadership of President Suleiman and the performance of the army, which he led until recently.
Soldiers are now deployed in most of the potential flashpoints, but as this week's violence in Tripoli showed, they seldom intervene during clashes between factions.
Another critical issue will be Lebanon's relationship with Syria.
It is here that the Lebanese may get an early indication of what to expect from the president.
Mr Suleiman is due to meet his Syrian counterpart at this weekend's Mediterranean Union meeting in Paris.
Observers often say that Lebanon is caught between major international and regional blocs - the West, Saudi Arabia and other Sunni Arab countries on the one side, with Syria and Iran on the other.
With a US election later in the year, continued tensions between Iran and the United States, as well as talks between Israel and Syria, there is considerable uncertainty about the future direction of the Middle East.
All of those factors will have a direct bearing on the prospects of this new government and of Lebanon's stability.
One thing that does appear certain is that this government will be relatively short-lived.
Elections are scheduled for next year and those polls may give a better indication of the future direction of Lebanon in the years to come.