Cairo: 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 Abdul Fattah Al Sissi has expressed concerns over militants who have capitalised 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 Al Sissi 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 Ebrahim 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 Al 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.

Al 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 Daesh that has seized large swathes of Iraq and Syria.

Security officials in Egypt fear that the militants want to topple Al Sissi and create a caliphate in Egypt.

The porous 1,115-kilometre border between Egypt and Libya makes it easy for militants to move in both directions.

Fifteen members of Daesh, led by an Egyptian and a Saudi national, travelled to Derna from Syria 15 days ago trying to rally support and establish an Islamic State branch in Libya.