Tunisia has completed a 200-km (125 mile) barrier along its frontier with Libya to try to keep out Islamist militants, and will soon install electronic monitoring systems, Defence Minister Farhat Hachani said on Saturday.
Libya's chaos since the fall of Muammar Gaddafi in 2011 has allowed Islamic State to gain a foothold there, and officials say militants who carried out two major attacks in Tunisia last year had trained in Islamist camps in Libya.
Troops have raised an earth wall and dug trenches 2 km (1.2 miles) from the Libyan border, and European and American military trainers will soon train Tunisian forces to improve electronic surveillance with cameras and radar, Hachani told reporters on a visit to the border.
"Today we finished closing it off, and this will help us protect our border, and stop the threat," he said.
Security forces said the defences had already helped to reduce smuggling.
Islamic State controls the Libyan city of Sirte and has attacked key oil installations as it expands beyond its heartland in Iraq and Syria.
More than 3,000 Tunisians have left to fight for Islamic State and other Islamist groups in Syria and Iraq, but Hachani said many had now returned to North Africa to join the group in Libya.
Since its own democratic revolution in 2011, Tunisia has been praised as a model of democratic transition, with free elections, a new constitution and a politics of compromise between secular and Islamist parties.
But last year's two major attacks, on a museum in Tunis and a beach hotel in Sousse, dealt heavy blows to its tourist industry, a mainstay of the economy.