A showdown is quickly building in the east Mediterranean over Libya, which could lead to even more violence in the troubled North African country.
The latest chapter in the bloody and chaotic history of Libya since the downfall of Muammar Qaddafi began with Tripoli government leader led Fayez Al Sarraj signing joint defence and maritime demarcation agreements with Nato member Turkey.
But the deal has sparked concern across the Mediterranean from Athens to Cairo, and has angered Libyan Speaker of Parliament Aqilah Saleh, who called the deal "unacceptable".
Egypt, Libya’s neighbour to the east, accuses Turkey of supporting militant groups and fomenting unrest in the region.
Turkish President Recep Tayyip Erdogan said on Thursday that his country could send troops to fight alongside the Tripoli government’s allied militias as early as January in the battle for the capital.
The Libyan National Army, backed by the eastern administration in Benghazi, launched an offensive in April to capture Tripoli from the militias.
But the fighting has become a long standoff with neither side being able to win decisively.
There has been media reports that Turkey will transfer militants from Syria to fight alongside the Tripoli militias.
Bloomberg reported on Friday that Ankara would send an ethnic Turkmen rebel group from Syria’s north-east and the Turkish navy to defend the Libyan capital, while the Turkish military would provide support and training.
Abdel Fattah El Sisi, Egypt’s President who led the 2013 removal of Mohammed Morsi, a Turkish-backed and divisive president, has repeatedly made it clear in recent weeks that his country would not tolerate “illegitimate foreign interference” in Libya.
Mr El Sisi said that what happened across Egypt’s 1,200-kilometre border with Libya directly affected his country’s national security.
Mr Erdogan said on Thursday that his government would submit a bill to Parliament allowing Turkey to send troops to Libya.
Mr El Sisi this month said he had no intention to send troops to bolster the LNA, and that “we will not directly intervene in Libya".
But his comments leave the door open to Cairo increasing its logistics and training to the LNA and possibly increasing aerial support.
Imad Hussein, editor of Al Shorouk, an Cairo daily that is close to authorities, issued a stern warning about military involvement in Libya.
Any military Egyptian boots on the ground in Libya, Hussein wrote, would create a quagmire similar to Cairo’s intervention in Yemen in the 1960s.
But the threats for Egypt remain.
In recent years, militants in Libya have waged deadly, cross-border attacks against Egyptian security forces and minority Christians travelling to remote monasteries near the border.
Already fighting a years-long insurgency by militants in the Sinai Peninsula, the cross-border desert attacks have prompted Egypt to commit vast resources to police its porous border with Libya and seek US help to strengthen its surveillance technology.
On several occasions, Egypt has announced that it carried out air strikes against militant positions in eastern Libya. One of those strikes was in response to the beheading of 21 Egyptian Christians in 2015 by ISIS.
But Egypt could use means short of direct military involvement to stop Turkey from gaining a foothold in Libya.
"Regardless of Turkey's goals and justifications, Erdogan's latest moves have doubled the chances of military operations and clashes," Nabil Fahmy, a former Egyptian foreign minister who now leads a think tank in Cairo, wrote in Al Masry Al Youm daily.
“Egypt may find itself forced to carry out specific and targeted military operations to deter Erdogan, or confront any additional escalation by him.”
Mohammed Salem, a retired UN diplomat and now a member of the Egyptian Council of Foreign Relations, said Egypt must avoid a drawn-out conflict in Libya similar to those in Syria and Yemen.
“It seems that, when it comes to Libya, the focus is exclusively on the prospect of a military conflict," Mr Salem said. "There has to be a diplomatic initiative that engages and contains Turkey and the National Accord government in Tripoli.
“But there are red lines, too. Egypt cannot allow a significant Turkish military presence in Libya that upsets the military balance in the area or negatively impact on Egypt’s security.”
Mr El Sisi has been investing time and effort in recent weeks to rally support to contain the issue.
Over the past week he has discussed Libya with foreign leaders including US President Donald Trump, Russian leader Vladimir Putin and German Chancellor Angela Merkel.
There has been little said about the substance of these talks but the language in statements clearly suggests Egypt is prepared to take action to stop Turkey gaining ground in Libya.
Egypt has another key interest in foiling Turkish plans in the eastern Mediterranean.
Ankara’s maritime agreement with Tripoli’s government, dismissed as illegal by Cairo and others, significantly expanded Turkey’s continental shelf.
This infringed on Egypt’s ambitious plans with Cyprus, Greece and Israel to turn the region into a global energy centre after the discovery of natural gas there in massive quantities.
Turkey has been unhappy that it was left out of these plans and has been trying to force itself into the scheme.
It has explored for gas off the shores of Cyprus, of which Turkey has occupied a third since 1974 when it invaded after a short-lived, Greek-inspired coup.
The EU imposed sanctions on Turkey for drilling for gas in the water off Cyprus, which is a member of the bloc.