ON AUGUST 7th only a few vehicles could be seen leaving the besieged town of Arsal on Lebanon’s border with Syria: tanks ferrying exhausted, chain-smoking Lebanese soldiers, microbuses packed with refugees and ambulances escorted by Lebanese army intelligence men. Two Syrian government warplanes circled ominously over the surrounding hills. For almost a week Arsal, a Lebanese Sunni Muslim town whose residents have deep ties to Syria's rebels, has been under the control of jihadists from Jabhat al-Nusra, al-Qaeda’s affiliate in Syria, and the Islamic State, an even more extremist group that grew out of al-Qaeda in Iraq. On August 2nd fewer than a hundred fighters crossed the border from Syria, joining fighters already inside the town and on the porous border. The move was prompted by the Lebanese security forces arrest of Imad Jomaa, a commander for Jabhat al-Nusra who had recently pledged loyalty to the rival Islamic State.The groups ransacked police stations and army barracks and kidnapped dozens of Lebanese security personnel.

The Lebanese army responded by shelling the town and deadly gunfights broke out along in the area. At least 17 Lebanese army troops have been killed since August 2nd. An unknown number of residents and refugees have died or been injured too. In one particularly gruesome tragedy, on August 6th a camp for Syrian refugees was shelled; local aid groups are reported to have found 30 charred corpses.

Pundits have long talked of Syria’s war spilling over into Lebanon but this has been the worst violence since the conflict began in 2011. Since the evening of August 6th a shaky ceasefire has been in effect to allow militants, desperate residents and refugees to leave. But it is far from over—on August 5th a group of Muslim scholars making an attempt to negotiate were ambushed by gunmen in the town.

Arsal’s vulnerability comes from its position on the border but also from its sorry state. Residents say the Lebanese government has for decades failed to provide electricity, water and medical facilities. Residents have long made money from smuggling and relying on the largesse of powerful national Sunni politicians.

Some say the town's two most prominent families, the Hujeiri and Fliti clans appear to be working with the jihadists. They control everything from lucrative cross-border smuggling to public projects, including the town's first ever hospital, built last winter. The hospital has a special wing reserved for injured rebels, many from Jabhat al-Nusra, which has been steadily packed as battles in the nearby Qalamoun have raged.Gunmen from Jabhat al-Nusra guard the mosque of Mustafa Hujeiri, a sheikh from the devout Salafist tradition, prompting local rumour that it serves as a conduit for cash and weapons flowing to Syria. Mr Hujeiri is currently holding at least some of the Lebanese security personnel, whom he has called his "guests".

Rifaat Nasrallah, a Christian businessman-cum-militia leader who works closely with Hizbullah, Lebanon’s Shia movement, says he and his men have been fighting jihadists every night in the surrounding hills for over a week. Rumours that Hizbullah will openly enter the fight for Arsal have raised long-running fears across Lebanon that sectarian bloodletting will follow.

Arsal residents reached by phone say most of the jihadists have left the town in the past hours. However they have simply moved back to hideouts in the surrounding hills on both sides of the border where caves have been turned into vast arsenals and where car bombs inside Lebanon and Syria are believed to be planned.

So few locals believe the fight is close to being over. Nadia, who owns a grocery shop near Lebweh, says she has faith in the Lebanese army but is scared. "I'm afraid that if our soldiers fail in this mission, we will all have to leave forever," she says, citing widely circulated videos of Islamic State jihadists beheading their enemies and destroying religious shrines. Back on the road running south to the Syrian border crossing, a bus driver ferried his now twice-displaced passengers back to Damascus, the Syrian capital. For some it looks safer than parts of Lebanon.