Tunisian forces repelled a jihadist assault Monday on a town near the Libyan border, killing 35 assailants in what authorities said was a thwarted effort to establish an Islamic emirate.

Among a total of more than 50 dead, 11 members of the security forces and seven civilians were killed in the fighting in Ben Guerdane that President Beji Caid Essebsi condemned as an “unprecedented” jihadist attack.

It prompted authorities to close the frontier and order a nighttime curfew.

Prime Minister Habib Essid, using an Arabic acronym for the Islamic State (ISIS) jihadist group, said the aim of the operation had been to set up a “Daesh emirate” in Ben Guerdane, but the army and internal security forces had thwarted the attackers.

For his part, Essebsi, in an earlier statement broadcast on state television, said the assault was “maybe aimed at controlling” the border region with Libya, and he vowed to “exterminate these rats”.

Residents of the border town told AFP the assailants appeared to be natives of the region.

They had stopped residents, checked their IDs apparently to seek out members of the security forces, and announced their brief takeover of the town as “liberators”.

“I was about to open my shop, at 5:30 (am), when I heard gunshots coming from not far from here,” said a grocer near Ben Guerdane hospital, asking not to be named.

He went to find out what was happening at the hospital, where he saw two jihadists drive off with an ambulance, an account confirmed by a medic.

Other jihadists pointed a gun at him, told him to kneel down and asked for his identity papers, which in Tunisia show your profession.

“I told him I didn’t have my ID on me. His comrade said: ‘Kill him.’ But instead he shouted out: ‘We are Al-Imara al-Islamiya (the Islamic emirate). We’ve come to liberate you.'”

The assailants, apparently working from a hit list, assassinated an anti-terrorist brigade official at his home, according to friends.

“They knew him! They knew him!” insisted the man’s uncle, Mustapha Abdelkebir, a civil society activist, as he shed tears of grief.

It was the second deadly clash in the border area in less than a week as Tunisia battles to prevent the large number of its nationals who have joined ISIS in Libya from returning to carry out attacks at home.

The jihadists have taken advantage of a power vacuum since the NATO-backed overthrow of longtime dictator Muammar Gaddafi in 2011 to set up bases in several areas of Libya, including the Sabratha area between Tripoli and the Tunisian border.

The government said that an army barracks and police and National Guard posts in Ben Guerdane came under attack in coordinated pre-dawn assaults.

The defence ministry said at least 35 jihadists, six members of the National Guard, two policemen, a customs official and a soldier died in the fighting, the defence ministry said. Seven civilians were also killed.

Seven militants were captured, the defence ministry said.

Hospital official Abdelkrim Chafroud said a 12-year-old boy was among the dead civilians.

An AFP correspondent reported that schools and offices in Ben Guerdane were closed and troops were posted on rooftops across town as helicopters hovered overhead.

Residents were being urged to stay indoors even before the 7:00 pm (1800 GMT) start of the nighttime curfew.

– Jihadist presence growing –

As well as closing border crossings with Libya, authorities also closed the main road north to the rest of Tunisia, the correspondent said.

Authorities said ground and air patrols along the border would be reinforced.

Essid, who is to hold a press conference on Tuesday, ordered the defence and interior ministers to Ben Guerdane to oversee operations against the jihadists.

Last Wednesday, troops killed five militants in a firefight outside the town in which a civilian was also killed and a commander wounded.

Troops have been on alert in the border area following reports militants had been slipping across since a US air strike on an IS training camp in Libya on February 18 killed dozens of Tunisian militants.

Deadly attacks by ISIS on foreign holidaymakers last year, which dealt a devastating blow to Tunisia’s tourism industry, are believed to have been planned from Libya.

Tunisia has built a 200-kilometre (125-mile) barrier that stretches about half the length of its border with Libya in an attempt to stop militants infiltrating.

– US air strike –

February’s US strike on the ISIS training camp outside Sabratha targeted the suspected mastermind of two of last year’s attacks, Noureddine Chouchane.

Washington has said Chouchane was likely among the dozens of militants killed, and that the strike probably averted a mass shooting or similar attack in Tunisia.

According to a UN working group on the use of mercenaries, more than 5,000 Tunisians have travelled abroad to join jihadist groups, many of them in Libya.

Western governments have been increasingly alarmed by the growing ISIS presence in Libya just 300 kilometres (185 miles) across the Mediterranean from Europe, and have made contingency plans for intensified military action.

Rival administrations which have vied for power since mid-2014 in Libya are being urged to sign up to a UN-brokered national unity government to facilitate the fight against the jihadists.