As part of a key compromise, the deal also gives the militant Hezbollah group and its allies veto over any government decision.
The Western-backed government and Hezbollah-led opposition held six days of Arab-mediated talks in Qatar before reaching the deal. The pact was immediately praised by Iran and Syria -- an endorsement that may fuel fears in the West over Hezbollah's growing political clout.
In a speech at the ceremony in the Qatari capital Doha, Prime Minister Fouad Siniora said it was "an exceptional agreement at an exceptional time," according to the BBC.
"We must ... pledge never to resort to arms to resolve our political differences," Siniora said. "We should accept each other and hold dialogue to solve the problems. We want to live together and we will continue that. We have no other choice."
But another leader of the Western-backed government, Saad Hariri, seemed to acknowledge his side had made big concessions, spurred by a burst of violence earlier this month.
"I know that the wounds are deep and my injury is deep, but we only have each other to build Lebanon," he said after the announcement of the deal, the Associated Press reported.
Hezbollah's top negotiator, Mohammed Raad, meanwhile, downplayed the group's perceived victory.
"Neither side got all it demanded, but (the agreement) is a good balance between all parties' demands," he said.
The opposition won both its demands with the deal: veto power in a new unity government, and an electoral law that divides up Lebanon into smaller-sized districts, allowing for better representation of the country's various sects, according to the AP.
Parliament will convene on Sunday to elect army chief Gen. Michel Suleiman as head of state, aides to Parliament Speaker Nabih Berri told Reuters in Qatar. The president's post has been vacant since November.
The talks in Qatar and the deal brought an end to Lebanon's worst internal fighting since the 1975-90 civil war. At least 67 people were killed when clashes broke between pro-government groups and the opposition Beirut and elsewhere earlier this month.
The agreement, a copy of which was obtained by the AP, says that the two sides "pledged to refrain" from resorting to violence to resolve disputes and that the "use of arms or violence is forbidden to settle political differences under any circumstances."
French Foreign Minister Bernard Kouchner said he was "personally very happy" about the agreement and said it was now "up to all the Lebanese to use this accord to build the basis for national reconciliation."
A top U.S. diplomat for the Middle East says the deal in Lebanon is a welcome development, although the agreement gives the military Hezbollah group more power. At the State Department, Assistant Secretary of State David Welch called the agreement "a necessary and positive step," according to news agencies. "It's not for us to decide how Lebanon does this."