At least 45 people have been killed in Tunisia after extremists attacked a town near the country's border with Libya.

The interior and defence ministries said in a statement that the Tunisian government has closed its two border crossings with Libya because of the attack.

The statement says 28 "terrorists" have been killed in the fighting, seven civilians and 10 members of Tunisia's security forces.

The attack comes amid growing international concern about Islamic State extremists in Libya.

A 12-year-old girl was among the civilians who were killed.

Interior ministry spokesman Yasser Mosbah earlier told The Associated Press the gunmen targeted a police station and military facilities at dawn on Monday in the border town of Ben Guerdane in eastern Tunisia.

The violence comes amid increasing international concern about Islamic State extremists in Libya. Tunisia's fledgling democratic government is especially worried after dozens of tourists were killed in extremist attacks in Tunisia last year.

The Tunisian military sent reinforcements and helicopters to the area around Ben Guerdane and authorities are hunting several attackers still at large. The ministry urged residents to stay indoors.

Last week, Tunisian security forces killed five heavily-armed men in an hours-long gunfight after they crossed into the country from Libya with a larger group.

Tunisian security forces had been placed on alert based on "precise information" of possible border infiltrations following the February 19 US raid on an IS camp near the Libyan town of Sabratha, not far from the Tunisian border, the statement said.

Defence minister Farhat Horchani said last week that German and American security experts were expected in Tunis on Monday to help Tunisia devise a new electronic video-surveillance system of its border with Libya.

Tunisia was targeted last year by three attacks that left 70 people dead and were claimed by IS. According to Tunisian authorities, the attackers had been trained in Libya.