RIYAQ, Lebanon, April 26 - The last of Syria's troops left Lebanon on Tuesday after a bittersweet ceremony near the border, ending a military presence that for 29 years helped Syria control Lebanon and confront Israel through proxy militias.
Some Lebanese politicians and American officials expressed concern, however, that Syria might continue exercising influence here through intelligence officials and its Lebanese political allies. And Secretary General Kofi Annan expressed concern at the United Nations that Lebanese militias, including Hezbollah, had not yet been disarmed.
As the remaining soldiers crossed into Syria - driven out by international pressure and by Lebanese demonstrations over the past two months - politicians here also acknowledged that serious challenges now faced a more independent Lebanon, not least a democracy hobbled by sectarian divisions and bitter memories of civil war. The first test is fast approaching, with the cabinet expected to call for new elections before May 31.
On Tuesday morning, Lebanese and Syrian military officers gathered at an airbase in this Bekaa town, about 10 miles from the Syrian border, to bid farewell to 300 or so crisply uniformed Syrian troops and top intelligence officers, and hundreds of other troops securing roads to the border. Military bands from both countries played as commanders exchanged medals before dignitaries and military attachés from numerous countries, including the United States, France and North Korea.
"Brothers in arms, thank you for your sacrifices," said Gen. Michel Suleiman, commander of Lebanon's army, who bid the soldiers goodbye with an Arabic term meaning "Until we meet again." "Together we shall always remain brothers in arms in the face of the Israeli enemy."
Prominently featured in the audience was Maj. Gen. Rustom Ghazali, Syria's latest top intelligence chief in Lebanon, a post from which Syria was widely believed to have held the reins of Lebanese politics for years.
Syria entered Lebanon in 1976, a year after civil war broke out, as part of an Arab peacekeeping force. But the Syrian role took a serpentine course. The government of the late Hafez al-Assad, father of the current Syrian president, Bashir al-Assad, befriended and betrayed various factions, and for the past 15 years, Syria was dominant.
The Syrians were invited in by Suleiman Franjieh, a Maronite Catholic who was then president, as a counterweight to Palestinian guerrillas who had allied with leftist Muslim forces. But the Christians later became enemies of the Syrians and, in recent years, their sharpest critics.
Meanwhile, while ostensibly championing the Palestinians, Syria set compliant Shiite Muslim militiamen against refugee camps in the 1980's. And the Syrians were blamed by most Lebanese for assassinations of prominent political figures.
The Israeli invasion of Lebanon in 1982 seemed likely at first to end Syrian influence. But then Bashir Gemayel, who was Israel's ally, was assassinated shortly after his election as president, and his militiamen massacred Palestinians. The United States sent a peacekeeping force but it left after 242 marines and sailors died in a Shiite suicide bombing. Israeli troops eventually withdrew under attacks by the Shiite group Hezbollah.
After another half-decade of civil war, a fragile peace was reached in 1989 and Syria was to leave. But Syria only solidified its power in 1990 when the United States and France, in effect, turned a blind eye in Lebanon and in exchange got a symbolic deployment of Syrian troops in the first Persian Gulf war.
By then, in the anarchic fighting, the Christian-led Lebanese Army had massacred a Christian militia and the Syrians, in turn, had attacked and crushed the Lebanese Army. At that point, the civil war ended with Syria firmly in charge.
Last September the United Nations, in Resolution 1559, called for Syria's withdrawal, and for the disarming of all militias in the country. Late last year, Prime Minister Rafik Hariri resigned his post and called for Syria to comply. He was assassinated Feb. 14, setting off popular demonstrations fueled by a widespread belief that Syria was involved in the killing. The protests only increased international pressure on Syria to get out.
"Syria has now fulfilled that demand," said Gen. Ali Habib, leader of the Syrian Army. "Syria never had any desires or ambitions in Lebanon except to preserve its unity."
Shortly after the two-hour ceremony ended, General Ghazali and his intelligence officers piled into cars and drove across the border. Buses and jeeps filled with troops followed. The last four Syrian soldiers in Lebanon, who had been holding watch at the border, left in a television van.
A United Nations team was given the task of verifying that the Syrians had indeed pulled out completely.
"I respect the Syrians for having left without any conflict with us," said Tanious Abu Hamad, mayor of Saghbin, who attended the ceremony. "But now it all comes down to us. Our problems are now our own."
The problems are numerous. Lebanon's Syrian-backed president, Émile Lahoud, remains in power; the security services are still modeled on Syria's and have a reputation for corruption, and the Lebanese political system, by law, remains built on sectarianism.
At the United Nations, Mr. Annan said the departure of the Syrians represented "significant and noticeable progress."
But in a report to the Security Council, he noted that there had been no action by Lebanon on disarming militias, armed Palestinian groups and vigilantes, as mandated by the Council, and that the Beirut government had not heeded calls to extend its authority to areas of southern Lebanon vacated by Israel in May 2000 and now under the authority of Hezbollah.
Meanwhile, the future of the economy, which depends on tourism and foreign investment, will remain uncertain as long as confidence in the government and the prospects for security are in question.
"We have clearly succeeded in our sovereignty revolution, but we have not yet succeeded in our democratic revolution," said Chibli Mallat, director of the Center for the Study of the European Union and a prominent lawyer in Beirut. "The revolution only succeeds when the president resigns and when the confessionalism in politics gives way to national representation." "Confessionalism" means sectarianism in Lebanese parlance.
But on Tuesday night, the Parliament was still squabbling over a districting law just two days before a constitutional deadline for scheduling elections in time to hold them by May 29, as Prime Minister Najib Mikati has promised.
"We are all waiting for the elections as a prerequisite for defining the role of Lebanon," said an opposition legislator, Nayla Mouawad.
In Syria the soldiers were met by rice-throwing well-wishers apparently organized by the government. But the sense of humiliation was hard to hide. The Syrians generally dismissed the Lebanese as ungrateful, said Sami Moubayed, a Syrian political analyst.
"But the intellectual elite understands very well how Syria's place in the world has changed," Mr. Moubayed said. "The nationalists among them feel that everything Hafez al-Assad built is being squandered."
Katherine Zoepf contributed reporting from Damascus, Syria, for this article, and John Kifner and Warren Hoge from New York.