The vow came at the close of a meeting of defence ministers in the southern city of Granada from the so-called 5+5 initiative set up in 2004 to boost cooperation in security matters among 10 nations from around the Mediterranean.
In a joint statement they promised to "work with a renewed strength" to "tackle the security changes that we face, in particular illegal immigration, organised crime and terrorism".
The 5+5 initiative also includes Tunisia, Mauritania, Morocco, Portugal and Malta.
Spanish Defence Minister Pedro Morenes, who hosted the gathering, expressed his "firm support" for the "legitimate government of Libya.
"We face common threats: Islamist terrorism, drug smuggling, human trafficking, massive illegal migration, all are factors that affect the Mediterranean coast," he said.
"International jihadist terrorism directly affects our nations but it is also affecting countries that are not part of the 5+5 and which have the capacity to influence in our nations."
Signup to our newsletter and follow us on Facebook and Twitter!
Several Islamist extremist groups are threatening the area, including jihadists from Al-Qaeda in the Islamic Maghreb who are active in Algeria and remain a major problem for Morocco.
The rise in Islamist violence regionally has contributed to a surge in refugees crossing the Mediterranean, which the United Nations refugee agency UNHCR said Wednesday has become "the deadliest route of all" for migrants.
The agency reported 3,419 deaths in the Mediterranean during attempted crossings this year as more than 207,000 people have attempted the sea crossing since the start of January.
That is nearly three times the previous known high of about 70,000 attempts in 2011, when the Libyan civil war was raging, the agency said.
Italy has been particularly affected by the rising number of migrants hoping to enter Europe by sea from Africa.
Ministers at the 5+5 summit also expressed concern over the degrading security situation in Libya, where over three years after dictator Moamer Kadhafi was toppled and killed, the country is awash with weapons as well as powerful militias and has rival governments.
An attempt to arrange UN-brokered talks between the warring factions in June was unsuccessful.
"We are worried by the situation observed in the state of Libya and we want to express our hope that this crisis will soon be solved, to restore peace and security in the country," the ministers' final declaration read.