BEIRUT, Lebanon (CNN) -- Celebratory gunfire could be heard across the capital after Lebanon's parliament elected Gen. Michel Suleiman as the nation's 12th president Sunday -- just days after the Lebanese government agreed to share power with Hezbollah.
In his remarks to parliament, Suleiman encouraged Lebanese citizens and leaders to embrace a new attitude and set aside secular and political differences.
He also spoke out against terrorism, and said he would like to see "brotherly" relations with Syria, Hezbollah's primary backer.
"We must energize institutions in this country, national institutions, so we can have common objectives, which will secure this nation and its people," Suleiman said. "Lebanon is a place where civilizations meet. This must motivate us to [work] to resolve our secular, political and economic problems, so we can return Lebanon to the international map."
Crowds cheered and waved Lebanese flags as news of the election circulated. Suleiman's election ends a six-month vacancy as the army chief succeeds President Emile Lahoud, who stepped down in November. Watch the challenges awaiting Suleiman »
"I invite you all, politicians and citizens, to open a new page entitled 'Lebanon and the Lebanese' so we can have a national project that we all agree [on] -- to arrive at what serves the nation," Suleiman told parliament, whose members gave him a standing ovation.
The parliament had tried 19 times to vote on a president, but failed because of disagreements over how to share power in a Cabinet.
However, Lebanon's Western-backed government and its Hezbollah-led opposition reached a deal last week aimed at ending an 18-month political crisis that pushed the country to the brink of civil war.
The agreement, reached in Doha, Qatar, under the mediation of an Arab League committee, paved the way for Sunday's election.
The deal calls for a consensus government in which the Cabinet would include 30 posts -- 16 for the majority, 11 for the opposition and three to be filled at the president's discretion.
The seat allocation was a key sticking point for the opposition, which wanted to ensure it had the power to veto major decisions. With 11 Cabinet posts, it will have that power.
In exchange for the veto power and a redistricting plan ahead of next year's elections, Hezbollah agreed to end its sit-in protest that has paralyzed downtown Beirut since late 2006.
Minutes after the deal was forged Wednesday, Hezbollah loyalists packed up the tents that had been blocking the six-block area of Beirut. Eager tourists flocked to the area where streets, shops and eateries had been closed for a year and a half.
Suleiman, 59, the consensus candidate, is viewed as a neutral party by Lebanon's political factions. The nation's previous presidents have been deemed pro-Syrian or pro-Western. In his 10 years as chief of the army, Suleiman is credited with unifying the splintered military.
However, he inherits a nation still experiencing deep divisions. Lebanon's elected, pro-Western government has long been locked in a power struggle with Hezbollah.
In public statements and demonstrations in recent years, the militant group threatened to use its power and popularity to oust the Sunni-led government, triggering fears of a civil war that could destabilize the already volatile region.
The Doha agreement was welcomed by Syria. Lebanese government leaders and their key ally, the United States, also approved of the compromise. Lebanese Prime Minister Fouad Siniora, who took part in the negotiations, called the agreement "a big accomplishment."
The agreement follows what many say is a major political victory by Hezbollah, whose armed supporters took to the streets of Beirut earlier this month after Lebanon's government banned a telecommunications system used by the Shiite militia.
Hezbollah leader Hassan Nasrallah called the government's attempts to control the militia "a declaration of open war" and vowed that his supporters would defend themselves.
Minutes after his address, Hezbollah gunmen exchanged fire with pro-government militias in the streets of Beirut. The violence spread across Lebanon and soon became the worst outbreak of internal strife since the end of its civil war in 1991.
The fighting ended a week later when the Lebanese government accommodated two key Hezbollah demands -- lifting a government ban of Hezbollah's telecommunications system and reinstating the chief of security at Beirut's airport.
Hezbollah has been linked to numerous terrorist attacks against American, Israeli and other Western targets. The United States lists it as a terrorist organization, but many in Lebanon and other parts of the Middle East -- particularly Shiites -- view Hezbollah militants as freedom fighters.
CNN's Cal Perry contributed to this report.