The signal to attack came from the mosque, sending dozens of fighters storming through the Tunisian town of Ben Gardane to hit army and police posts in street battles that lit the dawn sky with tracer bullets.

Attackers used a megaphone to chant "God is Great" and reassure residents they were from the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) - there to save the town near the Libyan border from the "tyrant" army.

Most were Tunisians themselves, with local accents, and even some familiar faces, officials and witnesses to last Monday's attack said.

Hours later, 36 fighters were dead, along with 12 soldiers and seven civilians, in an assault authorities described as an attempt by ISIL to carve out terrain in Tunisia.


READ MORE: Deadly clashes erupt near Libyan border


Whether the armed group aimed to hold territory as they have in Iraq, Syria and Libya, or intended only to dent Tunisia's already-battered security, is unclear. ISIL has yet to officially claim the attack.

But as fuller details of the Ben Gardane fighting emerge, the incident highlights the risk Tunisia faces from home-grown fighters drawn to Iraq, Syria and Libya who threaten to bring their war back home.

Despite Tunisian forces' preparations to confront returning fighters, and their defeat in Ben Gardane, Monday's assault shows how the country is vulnerable to violence spilling over from Libya as ISIL expands there.

Authorities are still investigating the Ben Gardane operation. But most of the fighters appear to have already been in the town, with a few brought in from Libya. Arms caches were deposited around the city before the assault.

 Are ISIL fighters making inroads in North Africa?

"Most of them were from Ben Gardane. We know their faces. They knew where to find the house of the counter-terrorist police chief," one witness, Sabri Ben Saleh, told Reuters news agency. "They were driving round in a car filled with weapons. My neighbours said they knew some of them."

Troops have killed 14 more fighters around Ben Gardane since Monday. Others have been arrested and more weapons seized.

After its revolt in 2011 to topple former President Zine El Abidine Ben Ali, Tunisia has struggled with growing militancy.

More than 3,000 Tunisians have left to fight with ISIL, according to government estimates. Tunisian security sources say many are in Libya and play a major role running training camps.

Gunmen trained in Libya were blamed for attacks on tourists at the Bardo Museum in Tunis a year ago and at a beach hotel in Sousse in June.

Last week's attackers were well-organised, handing out weapons to their fighters from a vehicle moving through the city, with knowledge of the town and its military barracks.

"We came across a group of terrorists with their Kalashnikovs, and they told us: 'Don't worry, we are not here to target you. We are the Islamic State and we are here for the tyrants in the army,'" said Hassein Taba, a local resident.

The attack tests Tunisia at a difficult time. After ISIL violence last year, the tourism industry that represents 7 percent of the economy is struggling to tempt visitors to return.

 Tunisia closes border with Libya after attack

With its new constitution, free elections, and secular history, Tunisia is a target for fighters looking to upset a young democracy just five years after the overthrow of dictator Ben Ali.

ISIL has grown in Libya over the past year and half, coopting local fighters, battling with rivals, and taking over the town of Sirte, now its main base.

That has worried Tunisian authorities, who have built a border trench and tightened controls along nearly 200-km of the frontier with Libya.

"The battle of Ben Gardane ... is proof enough that the Islamic State has cells far and wide," said Geoff Porter, at North Africa Risk Consulting. "But what these cells can reliably do ... and how they are directed by Islamic State leadership in Sirte, let alone in Iraq and Syria, is not known."

Tunisia's North African neigbours worry about the spillover effect of any further Western air strikes and military action against ISIL in Libya. 


OPINION: ISIL's gains in Libya and the case for intervention


After a US air strike killed 40 mostly Tunisian fighters in the Libyan town of Sabratha last month, Tunisian forces went on alert for any cross-border incursions.

Just days before the Ben Gardane attack, Tunisian troops killed five fighters who tried to cross from Libya.

But the fact that even after that setback ISIL mustered a force of 50 fighters to strike the town shows the group's ability to keep testing the Tunisian military.

 Tunisian families mourn losses after attack on town

Source: Reuters