Tunisia's prime minister says the army and private contractors are building a barrier along the border with Libya to keep out extremists following recent terror attacks claimed by the Islamic State group.

Habib Essid said construction aimed at rendering the border "impassable" by jihadi fighters and vehicles is expected to run through year-end.

Essid told Tunisian TV late Tuesday that the barrier will cover 168 kilometers (about 105 miles) of border with restive Libya and include fencing, a sand wall, trenches and surveillance posts.

Tunisia's government declared a state of emergency on Saturday — just days after a gunman killed 38 tourists in the coastal resort of Sousse. Three months earlier, attackers fired on tourists and others at the National Bardo Museum in the capital, Tunis, killing 22 people.