Islamist fighters attacked army and police barracks in the Tunisian town of Ben Guerdan near the Libyan border on Monday and at least 30 people, including civilians, were killed in the clashes, residents and the Interior Ministry said.

Authorities sealed off the nearby beach resort town of Djerba, a popular destination for foreign and local tourists, and closed two border crossings with Libya, the TAP state news agency said.

It was not immediately clear if the attackers crossed the border, but Monday's assault was the type of militant operation Tunisia's government had feared as it prepares for potential spill over from Libya, where Islamic State militants have expanded their presence.

Local television broadcast images of soldiers and police crouched in doorways and on rooftops as gunshots echoed in the centre of the town. Bodies of dead militants lay in the streets near the army barracks, local residents said.

"I saw a lot of militants at dawn, they were running with their Kalashnikovs," Hussein, a resident, told Reuters by telephone. "They said they were Islamic State and they came to target the army and the police."

Soldiers killed 21 militants and arrested six after they attacked military and police posts, the Interior Ministry said. Hospital sources said at least seven civilians were killed along with a soldier and a customs agent.

While Tunisia has been held up as a model of democratic transition since its 2011 uprising against ruler Zine El-Abidine Ben Ali, the North African country is also caught up in a struggle with Islamist militancy.

More than 3,000 Tunisians have left to fight with Islamic State and other groups in Syria and Iraq. Tunisian security officials say increasingly they are returning to join the militant group in Libya over the border.

Since the fall of Muammar Gaddafi five years ago, Libya has slipped into chaos, with two rival governments and armed factions struggling for control. Islamic State has grown in the turmoil, taking over Sirte city and drawing foreign recruits.

Tunisian forces have been alert for possible infiltration since last month when a U.S. air strike targeted mostly Tunisian Islamic State militants at a camp near the border in Libya's Sabratha.

Western military advisers are starting to train Tunisian border forces to help better protect the frontier with electronic surveillance and drones and authorities have built a trench and barrier to help stop militants crossing.

Islamist militants trained in Libyan jihadist camps carried out several attacks on Tunisia last year, including gun assaults on the Tunis Bardo museum and a Sousse beach hotel targeting foreign tourists. 

Related Story