At least 12 people have been killed and 100 wounded in the Lebanese city of Tripoli in clashes between opponents and supporters of Syria's president.
Leaders of the Sunni Muslim district of Bab al-Tabbana and the Alawite district of Jabal Muhsin declared a ceasefire on Wednesday after two days of clashes.
Fighting died down in the late afternoon, after the truce initially appeared to have been ignored.
Earlier, the army tried to stop the violence but was forced to retreat.
Sectarian tensions in Tripoli have been aggravated by the conflict in Syria.
President Bashar al-Assad is an Alawite and members of the heterodox Shia sect occupy key positions in the government and security forces.
Syria's majority Sunni community has been at the forefront of the revolt against the state and has borne the brunt of the crackdown during the conflict, which the UN says has left more than 18,000 people dead.
Two of those killed were identified as residents of Jabal Muhsin, which overlooks the predominantly Sunni area of Bab al-Tabbana where five people died, medical sources said.
A 13-year-old boy and the wounded a six-year-old were also among the dead, officials told the AFP news agency.
The army deployed troops in the areas in a bid to intervene, but they were forced to pull out after coming under attack and suffering casualties.
Lebanese Prime Minister Najib Mikati appealed to both sides to end the "absurd battle".
"We have repeatedly warned against being drawn into this blaze that has spread around Lebanon," he said, speaking of the conflict in neighbouring Syria.
Mr Mikati also urged Tripoli residents "not to allow anyone to transform you into ammunition for someone else's war", and warned that the security forces had been told to "bring the situation under control, to prohibit any armed presence and to arrest those responsible".
Later, political and religious leaders in Bab al-Tabbana and Jabal Muhsin agreed to implement a ceasefire.
By late afternoon, a fragile calm had descended on the area, although sporadic sniper fire continued, the BBC's Barbara Plett reports from Tripoli.
Tripoli, a city of nearly 200,000 people and Lebanon's second largest, is one of the country's most volatile sectarian faultlines, with a small Alawite community living in the midst of a Sunni majority.
Violence has flared several times, including in early June when 15 people were killed, but locals say the last two days of clashes have been particularly intense. One witness said heavier weapons were being used, and over a larger area than normal.
Our correspondent says government policy has been to try to disassociate the country from the Syrian crisis, amid concern that it might re-ignite the divisions that fuelled Lebanon's own 15-year civil war.
But the more sectarian the violence becomes in Syria, the harder it is to prevent it from seeping across the border, she adds.
Syria was the dominant foreign power in Lebanon for some 30 years and attitudes to the conflict which erupted there last year colour Lebanese politics beyond Tripoli.
Last week, a Lebanese Shia Muslim clan kidnapped dozens of Sunnis in retaliation for the abduction of a Lebanese Shia man by rebels in Syria.
The rebels had accused the man, Hassan Mekdad, of being a member of the powerful Shia Islamist movement, Hezbollah, who had entered the country to fight for the government. However, Hezbollah has denied any connection with the clan member or the kidnappings.