Tunisian Prime Minister Habib Essid says Islamic State militants carried out Monday's huge raid on Ben Guerdan that killed 55 people in an attempt to control the town and expand their territory.
Tunisia has become increasingly concerned about violence spilling across its frontier as Islamic State has expanded in Libya, taking advantage of the country's chaos to control the city of Sirte and setting up training camps there.
Dozens of militants stormed through the border town of Ben Guerdan on Monday attacking army and police posts and triggering street battles during which troops killed 36 fighters.
Twelve soldiers and seven civilians also died during the attack.
Essid said officials were still investigating whether the group of 50 militants had infiltrated across the frontier from Libya, though officials found three caches of arms, explosives and rockets in Ben Guerdan after the attack.
"They wanted to take over the barracks and police stations and gain territory, but our forces were ready," Essid told reporters on Tuesday.
"They thought it was going to be easy and the people of Ben Guerdan would help them. But Tunisians would never accept them."
The attack was one of the worst in Tunisia's history and followed three major Islamic State assaults last year, including gun attacks on a museum in Tunis and a beach resort in Sousse that targeted foreign tourists.
Since its 2011 revolt to oust autocrat Zine El-Abidine Ben Ali, Tunisia has battled a growing Islamist militancy at home and more than 3000 Tunisians have left to fight for Islamic State and other jihadist groups in Syria and Iraq.
But the increasing chaos in Libya, where two rival governments and armed factions are battling for control, has allowed Islamic State to thrive just over Tunisia's border, and the government has been preparing for potential attacks.