Tunis - Tunisia may take extraordinary measures in case of "an imminent danger that threatens the country's security and independence," said President Beji Caid Essebsi on Monday, hours after clashes with militants that claimed the lives of at least 45 people."The prime minister has informed me of the measures taken, shutting down the border with neighbouring Libya and imposing a curfew in the city," Essebsi said in a televised speech. Authorities have already closed the Ras Jedir border crossing with Libya, as well as the island of Djerba, a tourist destination, to prevent the infiltration of militants, the state-run Agence Tunis Afrique Presse reported.Essebsi said all measures he is considering are allowed by the constitution.The clashes first broke out at dawn when gunmen attempted to storm military and security barracks and sites in Begardene, which lies near the border with Libya, leading to confrontations with security force members, Tunisian Defence Ministry spokesperson Belhassen Oueslati said. Twenty-eight suspected militants were killed and seven others arrested during the fighting in Begardene, the statement said.Ten members of the security forces and seven civilians were killed throughout the clashes. Nine security forces were also injured in the process. "The attack was systematic and organized. It might have aimed at declaring a new 'state'," Essebsi said, possibility in reference to the militants being members of Islamic State.Essebsi had earlier held a meeting with the prime minister and the ministers of defence and interior to discuss the situation.Hot pursuitAn operation is under way to hunt down the militants who managed to flee the scene. Security forces have blocked all roads leading to Begardene. The Interior Ministry announced it had full control of the city. Joint army-police patrols have been deployed in the city with assistance from the air forces, the official news agency reported. It was not immediately clear whether the fighting continued.The Tunisian Interior Ministry imposed a curfew in Begardene scheduled to begin at 19:00 local time (18:00 GMT) and end at 05:00 (04:00 GMT), prompting schools to shut their doors and most commercial activities to stop in the city. The ministry has not announced for how long the curfew will last.The Interior Ministry called on Begardene residents to remain inside their homes and asked reporters not to go to the city.In November last year, Essebsi declared a state of emergency throughout the country after an attack by a suicide bomber on a bus carrying presidential guards claimed the lives of 12 people.On Wednesday, Begardene was the scene of deadly clashes between security forces and Islamist militants who had reportedly sneaked in from Libya.Tunisia has experienced a series of deadly attacks during the past year.The Islamic State terrorist group, which is active in Libya, has claimed responsibility for some of the attacks, including a gun attack that killed 21 tourists and a policeman at the Bardo museum in the heart of the capital Tunis. Last month, Tunisia completed a sand barrier and trench running half the length of its border with Libya. Work on the barrier began after 38 tourists were killed in a rampage by a lone gunman in a beach resort in Sousse, south of the capital, Tunis, in June, 2015.Libya has been beset by instability since the overthrow in 2011 of dictator Muammar Gaddafi.