The fighting in the border town of Ben Guerdane in eastern Tunisia comes amid increasing concern that violent extremism in Libya could destabilize the region.
The government closed its two border crossings with Libya because of the attack that left 28 "terrorists," seven civilians and 10 members of Tunisia's security forces dead, the Tunisian interior and defense ministries said in a statement.
A 12-year-old girl was among those who were killed.
Tunisia's fledgling democratic government is especially worried about the presence of IS in Libya after dozens of tourists were killed in extremist attacks in the country last year.
More From This Section
Today, gunmen targeted a police station and military facilities at dawn in Ben Guerdane, Interior Ministry spokesman Yasser Mosbah told The Associated Press.
France's foreign ministry condemned the attacks and identified the gunmen as "terrorists coming from Libyan territory."
"This attack is just reinforcing the urgent need for a political solution in Libya," the ministry said in a statement, adding that the country was targeted because of its "exemplary democratic transition."
Hospital official Abdelkrim Sakroud said on state radio that three corpses had been brought in, including that of the 12-year-old girl.
The Tunisian military sent reinforcements and helicopters to the area around Ben Guerdane and authorities were hunting several attackers still at large. Officials urged residents to stay indoors.