Guns fell silent in the northern Lebanese city of Tripoli on Monday after two days of deadly battles between the army and Islamist gunmen, some of the worst fighting to spill over into Lebanon from Syria's civil war next door.
The army said it had taken the militants' last position in the city's Bab al-Tabbaneh district, focus of much of the fighting. It issued a statement saying gunmen who had fled should turn themselves or be hunted down.
At least 11 soldiers, eight civilians and 22 militants have died in the fighting, security officials say.
The quieter morning followed battles overnight between the army and gunmen in areas surrounding Tripoli, a predominantly Sunni Muslim city where fighting linked to Syria's civil war has erupted several times in the last three years.
"The operation is over and the army is entering areas where the gunmen were entrenched in order to clear them," Samir Jisr, a Sunni politician from Tripoli, told Reuters.
The fighting marks the worst spillover of Syria-related violence into Lebanon since early August, when Islamist insurgents affiliated to the Nusra Front and Islamic State staged an incursion into the border town of Arsal and took around 20 soldiers captive.
Three have been executed and the Nusra Front has threatened to kill a fourth in response to the army operation in Tripoli.
The latest fighting erupted after an army raid on a militant hideout last Thursday. The detained leader of the cell has told investigators its plan was to set up a safe haven for Islamist militants in villages near Tripoli, security sources said.
The Syrian war has triggered Lebanon's worst instability since its own 1975-90 civil war. There have been several rounds of fighting in Tripoli since the Syria war erupted in 2011.
Political conflict has left Lebanon without a president since February when President Michel Suleiman's term expired.
Fighting in Syria has divided its smaller neighbour along sectarian lines, with Sunnis supporting Syrian rebels and Shi'ites backing President Bashar al-Assad. Hardline Islamist groups have won a degree of support among Lebanese Sunnis.
Prime Minister Tammam Salam, the most senior Sunni in the Lebanese government, met ministers and security officials on Monday and said "it was necessary to continue the confrontation", his office said in a statement.
"The government stands united behind the legitimate military security forces in the battle they are fighting to strike the terrorists and restore security to Tripoli and the north."
The area taken by the army on Monday included a mosque being used as a base by the gunmen in Bab al-Tabbaneh. Hundreds of families left the neighbourhood under a humanitarian ceasefire requested by local Sunni leaders.
A brief gunfight ensued as soldiers entered and started to comb the area. It was not immediately clear where the gunmen had gone. Security sources said some may have left with the civilians.
Fighting has also taken place in other parts of the north, near the towns of al-Minya and Bahneen, where at least two soldiers were killed in an ambush. The army used helicopter gunships to fire at militant positions for the first time in recent years.
Politicians across Lebanon's deeply divided political field have condemned the violence in Tripoli, Lebanon's second largest city and a historic base for Sunni Islamist groups.
The precise affiliations of all the fighters taking part in the clashes were not immediately clear. Security sources say they include both Lebanese and Syrian supporters of the hardline Sunni Islamist groups Islamic State and the Nusra Front.
The Nusra Front is the Syrian affiliate of al Qaeda. Islamic State is an al Qaeda offshoot that controls swathes of both Syria and Iraq, targeted by a U.S.-led campaign of air strikes in those two countries.
Lebanese Interior Minister Nohad Machnouk said in remarks published on Monday that the Tripoli gunmen numbered no more than 200 and were from both Lebanon and Syria.
Many Sunni Syrian rebels and hardline Lebanese Sunni Islamists accuse Lebanon's army of working with the Lebanese Shi'ite movement Hezbollah, which has sent fighters to aid Assad, a member of the Shi'ite-derived Alawite minority.