Libya is sinking ever deeper into violent chaos. A number of militias from various cities and tribes are warring with each other, and the fact that there are two rivalling parliaments shows just how divided the country really is. Since August 2014, Islamic insurgents have been ruling in Tripoli, forcing the internationally recognized parliament to move its seat eastward, to Tobruk.

Despite the fact that leading representatives, with the mediation of the United Nations, have agreed to a new peace accord and thus increasing pressure on the rival Islamist government in Tripoli, the lack of centralized political leadership has led to an escalation of extremism in Libya.

The security sector reform along with border control, are in fact the internal priorities for the country, representing a huge challenge for its own survival.

The lack of an effective control over its territory by the government authorities paved the way to the arise of extremist organizations, terrorists and drug traffickers, who are active mainly in the south of the country. The consequences are felt in the entire area of the Maghreb and the Sahel, already experiencing violence and instability. A recent UN report, has traced the arms trafficking, starting from Libya and reaching more than a dozen countries, including Mali, Egypt and Syria.

Moreover, the breakdown in its central authority has had serious implications for Libya’s own domestic stability. The lack of reliable security institutions, the persistence of powerful local armed militias and the proliferation of weapons have so far blocked any possible progress of the country to safety and stability, with heavy consequences for the entire region and the international community as a whole.

In this challenging environment, the economy is also suffering, damaging the interests of both African and non-African countries. For example, oil productions and exports have fluctuated wildly and are expected to operate significantly under-capacity for the foreseeable future. However, the most significant risks to Libyan neighbors are posed by the deterioration of centralized authorities, given Libya’s proximity to significant energy productions. Therefore, Libya’s loss of control over its borders will continue to be a pressing issue for regional actors and Western powers with economic and political links to North Africa and the Sahel.

The absence of an internationally recognized Libyan government unable to secure its own borders and the presence of a vast desert territory leaves a large area permeable to the region’s ample security threats.

The main problem in Libya, since 2011, has been the lack of security that has undermined the efforts to build functioning and reliable political institutions, facilitating on the contrary the advance of extremist groups and jihadi movements, across the entire region.

Egypt can be considered as the neighbor that is affected the most by IS control over Libyan cities. The Egypt-Libya border is over 1,200 km long; it is almost entirely open desert and virtually impossible to secure, especially given Egypt’s stretched military resources.

In this situation, smuggling of weapons and munitions from Libya would be similarly hard to interdict. Is therefore understandable how Egypt is concerned about the extremist threat. Hundreds of thousands of Egyptians live and work across the border in Libya, vulnerable to the country’s unraveling and the widening violence. At the social level, the massive return of Egyptian workers to their country will place heavy burdens on the country itself, in light of the authorities’ inability to provide returnees with employment opportunities. This means that Egypt is harmed the most by the consequences of the Libyan conflict.

The second most affected country is Tunisia. The Libyan crisis has already left its military, economic and social repercussions on Tunisia. In Libya, there are currently at least 1,500 fighters, trained and armed, and they undoubtedly would like to return to their country.

The Tunisian state is unable to bear the burden of receiving a million of refugees, in addition to tens of thousands of foreigners already living in Libya. After declaring a state of emergency following last month’s attack in Sousse, on the Gulf of Hammamet, the Tunisian government has announced plans for a wall that is projected to stretch 160 km inland from the coast, which is forecast to be completed by the end of this year. In fact, Tunisian Prime Minister Habib Essid said that Libya had become the “biggest dilemma” affecting Tunisia, confirming that the border construction project aims to stop terrorist groups from infiltrating.

Another country that is deeply affected by the situation is Algeria, which shares a border of 1,000 km of open desert that witnessed several infiltration operations by Al-Qaeda affiliate groups following the collapse of Muammar Gaddafi’s regime. The Algerian authorities have deployed thousands of military personnel in the past few months to enhance the security situation on the border area with Libya.

It is in response to the international calls to eliminate terrorist networks operating out of this relatively ungoverned land that the Algerian government has now stepped up patrols and militarization of this border region. As of May 2014, Algeria has closed 6,385 km of its borders with Mauritania, Mali, Niger and Libya, as a concerted effort to maintain and secure its economic and political relations with EU and NAFTA countries.

The Libyan government must therefore take bold steps to integrate marginalized communities into Libyan society. The economic incentives for local communities to seek income from cross-border trade must be swept away by spurring local development and tackling social grievances. This will require, in particular, the establishment of more robust government institutions in Libya’s south and east.

Nevertheless, it must be also mentioned that Libya has moved to cooperate with its neighbors on border security. In the last few years, it has signed bilateral border agreements with Algeria and Tunisia, a trilateral agreement with Chad and Sudan on surveillance, a military cooperation agreement with Egypt, as well as a multinational agreement with Chad, Nigeria, Algeria and Sudan to establish a joint security committee to explore further areas of border cooperation.

Yet, despite these advances, Libya still has a long way to go before its border security situation improves.

In the near term, it is crucial for the main political, trade union and civil society forces – both Islamist and non-Islamist – to maintain a consensual approach to public security and for the authorities to adopt a calmer anti-terrorist discourse in order to prevent renewed polarization.