At least 45 people have been killed in clashes between security forces and armed men in a Tunisian city near the border with Libya.

The Tunisian interior ministry said at least 28 attackers, 10 soldiers and seven civilians were killed in Monday's gun battle in Ben Gardane.

The attackers simultaneously targeted an army barracks and national guards with heavy weaponry, including rocket-propelled grenades.

An ambulance was also stolen in the clashes.

While the situation has calmed down, authorities said a curfew will be implemented in the city on Monday evening.

"We have decided to impose a curfew in Ben Gardane on both vehicles and pedestrians ... starting from today [Monday] between 7pm [18:00 GMT] and 5am [04:00 GMT]," an interior ministry statement said.

A security and military campaign began last week in Ben Gardane, after Tunisian security officials said "terrorist groups" sneaked into the country.

Officials said the campaign followed raids in Libya against fighters of the Islamic State of Iraq and the Levant (ISIL) group.

Fighters trained in Libya carried out several attacks inside Tunisia last year.

Al Jazeera's Nazanine Moshiri, reporting from Tunisia, said Ben Gardane is a strategically important town that is regarded as the "gateway to Libya". It serves as a hub for arms trafficking and smuggling of everyday goods.

READ MORE: Hopes of a better life in Tunisia hang by a thread

"Tunisia has built a fence along the border with Libya but that doesn't seem to stop the movement of armed attackers coming in from Libya and targeting the army and security forces," she said.

"In the past week we have seen several incidents of people coming across."

Habib Essid, Tunisia's prime minister, ordered the defence and interior ministers to head to Ben Gardane to oversee operations against the members of the armed group.

Last Wednesday, troops killed five armed men 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 that fighters had been slipping across since a US air strike on an ISIL training camp in Libya on February 18 killed dozens of Tunisian fighters.

At least four of the five fighters killed in last week's firefight were Tunisians who had entered from Libya in a bid to carry out attacks in their homeland, the interior ministry said.

Deadly attacks by ISIL 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 barrier that stretches about half the length of its border with Libya in an attempt to stop fighters infiltrating.

Speaking to Al Jazeera from Tunis, journalist Nicholas Noe said the latest attack is a "significant turn" for Tunisia and the regional security.

"It's been something that we have been predicting for months," he said.

The situation in Libya and the growing ISIL presence are having a spillover effect in Tunisia, he said.

"This could just be the beginning" of an even wider conflict.