Jihadists who occupied eastern Lebanon's Arsal near the Syrian border have agreed to leave in 24 hours and to release military and police hostages, Sunni clerics who mediated said Wednesday.
A ceasefire has been "extended to 7 pm on Thursday (1600 GMT) following an agreement between Lebanon's prime minister, the army command and the other concerned parties," chief negotiator Sheikh Hossam al-Ghali said.
"Fighters in Arsal have started to head across the Lebanese border" into Syria, Ghali said.
But the fate of the deal was unclear as security sources reported intermittent clashes and army shelling just hours after it was announced.
The clerics went to Arsal to negotiate an end to clashes between the army and jihadists that began in the area on Saturday, killing at least 17 soldiers.
An initial truce was expected to run until Wednesday evening, allowing talks to continue and the evacuation of the wounded and trapped civilians.
Lebanon's army says at least 22 of its soldiers have gone missing in the fighting, and are assumed to be held hostage by the militants, along with an estimated 20 policemen.
Another negotiator and fellow cleric, Samih Ezzedine, said: "The remaining armed men have undertaken to leave Arsal completely within 24 hours.
"They asked not to be shot at as they withdraw, and if that happens the whole agreement will be in jeopardy," he said.
"All the prisoners are alive and despite difficult negotiations we have clear and positive promises they will be released. I hope that will happen on Thursday," Ezzedine said.
However, the blocking of an aid convoy for Arsal by residents of the neighbouring Shiite village of Labweh set off sectarian tensions.
In the northern city of Tripoli, a homemade device exploded, wounding an unspecified number of people, a local security source said.
Signup to our newsletter and follow us on Facebook and Twitter!
Protesters, meanwhile, set ablaze tyres on roads in Sunni districts of the city and on a road in the eastern Bekaa, AFP correspondents said.
An Arsal resident told AFP during the day that many of the jihadists appeared to have withdrawn from its streets.
The UN agency for refugees UNHCR said earlier in the week it had received reports from local field hospitals of 38 people killed and 268 wounded, though there was no official confirmation.
The fighting has prompted Lebanon's army chief to call for more international aid, and on Tuesday night, Lebanon's former prime minister Saad Hariri announced Saudi Arabia had pledged $1 billion.
The new aid pledge came after Saudi Arabia and France said they would both work to speed up implementation of a separate $3 billion arms deal for Lebanon.
That deal, announced last December, involves Saudi financing for the purchase of French equipment, but a list of what will be obtained has yet to be finalised.
The clashes in Arsal are the most serious in the border region since the Syrian conflict erupted in March 2011.
On Wednesday afternoon, an AFP correspondent said ambulances were entering Arsal and a military truck had evacuated some civilians.
- Stability fears -
The fighting has raised fears about the stability of Lebanon, which is hosting more than one million Syrian refugees and has seen existing political and sectarian tensions heightened by its neighbour's war.
Many of Lebanon's Sunnis, including residents of Arsal, back the uprising against Syria's President Bashar al-Assad.
But much of the country's Shiite community backs Assad, and the powerful Shiite Hezbollah movement has sent fighters to bolster his forces against the rebels.