tunisia security
Tunisia announced that it would build a wall along its border with Libya after a series of attacks from insurgents. In this photo, national guard members patrol at the beach near the Imperiale Marhaba hotel, which was attacked by a gunman in Sousse, Tunisia, July 1, 2015. Reuters/Zohra Bensemra

Tunisia's government said Tuesday it will build a wall along its border with Libya in order to counter the inflow of insurgents. The move comes after a series of attacks were launched by Islamic extremists who traveled across the porous border between the two North African countries.

The wall is expected to cover about a third of the 310-mile border and will be completed by the end of the year, Tunisian Prime Minister Habib Essid said, according to Bloomberg. Essid added that construction work had already begun but warned that protecting the border would be "difficult, very difficult."

Since unrest swept across the Islamic world in 2011, Tunisia has emerged as a relatively stable and democratic country, and has managed to avoid the turmoil and militancy that plague countries like Syria, Libya and Egypt. However, Tunisia has faced numerous attacks from militants of the Islamic State group, including a June beachfront attack that killed 38 tourists, and a shooting attack on its Bardo museum in March.

A state of emergency was declared in Tunisia after the beachfront shooting. Both the incidents targeted the tourism sector, a major part of the country's economy that accounts for about 15 percent of its GDP.

Tunisia had already sealed its main border crossing to Libya last August after thousands of Egyptians and other foreign nationals fleeing violence in their home countries tried to storm the passage. The government also called on its estimated 50,000 to 60,000 nationals living in Libya at the time to leave "as soon as possible" in the face of the ongoing violence.

Libya has struggled to contain the outbreak in violent insurgent movements since the overthrow of former ruler Muammar Gaddafi in 2011. However, the country is currently torn between two rival governments battling for control, while numerous militias, many whom are tied to al Qaeda or ISIS, are emerging strong amid the chaos.