Egypt will train Libyan forces to fight terrorism and help secure a shared border, the prime ministers of the two states announced in Cairo on Wednesday, stepping up efforts against Islamist insurgents in both countries.
Egyptian President Abdel Fattah al-Sisi has expressed concerns over militants who have capitalized on the chaos in post-Gaddafi Libya to set up operations there and sneak across the border into Egypt.
They have forged ties with Egypt's Ansar Bayt al-Maqdis, the Sinai-based militant group that has stepped up attacks on soldiers and policemen since Sisi as army chief removed the Muslim Brotherhood from power last year.
Hundreds of security forces have been killed.
"We need to urgently support all the needs of our (Libyan) brothers to coordinate at the highest level in all areas...in the fields of security and we emphasize the exchange of information to combat terrorism...and also emphasize border security and control," Egyptian Prime Minister Ibrahim Mehleb told a news conference.
Reuters reported last week that Egypt had offered to train pro-government forces battling rival armed groups in Libya to help address what it says is a threat to its own stability.
The arrangement was publicly announced in Cairo, where Libyan Prime Minister Abdullah al-Thinni expressed alarm over Islamist militants controlling large parts of his country.
"We are facing terrorism ... and terrorism must be faced with strength and power and requires building and training cadres capable of confronting these terrorists," said Thinni.
He is recognised internationally but is currently based in the city of Tobruk in the east -- near the Egyptian border -- having lost control of the capital to a rival prime minister and parliament.
Both prime ministers stressed that extensive cooperation was needed to stem the tide of Islamist militants in chaotic Libya.
Thinni said his visit was intended to coordinate the beginning of "operational plans" to secure the border through bilateral military cooperation and "boosting the efficiency of army units and training the police."
The lawlessness of eastern Libya has enabled militants to set up makeshift training sites just a few kilometres from Egypt's border, according to Egyptian security officials.
Some Islamist militants in the Libyan coastal town of Derna have declared allegiance to the Qaeda breakaway Islamic State that has seized large swathes of Iraq.
Security officials in Egypt fear that the militants want to topple Sisi and create a caliphate in Egypt, inspired by Islamic State fighters which control large parts of Iraq and Syria.
The porous 1,115-kilometer border between Egypt and Libya makes it easy for militants to move in both directions.
Fifteen members of Islamic State, led by an Egyptian and a Saudi national, traveled to Derna from Syria 15 days ago trying to rally support and establish an Islamic State branch in Libya.