Libya's internationally recognised government has formally requested from Turkey "air, ground and sea" military support to fend off an offensive of eastern forces to take the capital Tripoli, a government official has said.
It comes after Turkey's President Recep Tayyip Erdogan said earlier his country will send troops to Libya as soon as next month.
The decision puts the North African country's conflict at the centre of wider regional frictions.
Libya's internationally recognised Government of National Accord has been struggling to fend off General Khalifa Haftar's forces from eastern Libya, which have been supported by Russia, Egypt, the United Arab Emirates and Jordan.
Mr Haftar's forces were not immediately available for comment.
They have failed to reach the centre of Tripoli but have made small gains in recent weeks in some southern suburbs of the capital with the help of Russian and Sudanese fighters, as well as drones shipped by the UAE, diplomats say.
The Chinese-made drones have given Mr Haftar "local air superiority" as they can carry over eight times the weight of explosives than the drones given to the GNA by Turkey and can also cover the whole of Libya, a UN report said in November.
Last month, Turkey signed two separate accords with the GNA, led by Fayez al-Serraj, one on security and military co-operation and another on maritime boundaries in the eastern Mediterranean.
The maritime deal ends Turkey's isolation in the East Mediterranean as it ramps up offshore energy exploration that has alarmed Greece and some other neighbours. The military deal would preserve its lone ally in the region, Libya.
"Since there is an invitation (from Libya) right now, we will accept it," Mr Erdogan told members of his AK Party in a speech. "We will put the bill on sending troops to Libya on the agenda as soon as parliament opens."
The legislation would pass around 8 or 9 January he said, opening the door to deployment.
For weeks Turkey has flagged the possibility of a military mission in Libya, which would further stretch its armed forces less than three months after it launched an incursion into northeastern Syria against a Kurdish militia.
Turkey has already sent military supplies to the GNA despite a United Nations arms embargo, according to a UN report seen by Reuters last month.
Mr Erdogan visited Tunisia yesterday to discuss co-operation for a possible ceasefire in neighbouring Libya.
Today he said Turkey and Tunisia had agreed to support the GNA.
Russia has voiced concerns over a possible Turkish military deployment to Libya in support of the GNA.
This afternoon Russian President Vladimir Putin and Italian Prime Minister Giuseppe Conte agreed that the situation in Libya must be resolved in a peaceful way, the Kremlin said.
In a phone call, Mr Putin and Mr Conte also discussed Syria and the results of the Normandy summit on Ukraine, the Kremlin said on its website.
Mr Erdogan has previously said Turkey will not stay silent over mercenaries from the Kremlin-linked Wagner group supporting Mr Haftar.
"Russia is there with 2,000 Wagner (fighters)," Mr Erdogan said, also referring to some 5,000 fighters from Sudan in Libya. "Is the official government inviting them? No."
"They are all helping a war baron (Haftar), whereas we are accepting an invitation from the legitimate government of the country. That is our difference," he said.
Mr Haftar's Libyan National Army has been trying since April to take Tripoli from the GNA, which was set up in 2016 following a UN-brokered deal.
The UAE, Egypt and Jordan have for years provided military support for Mr Haftar's forces, UN reports have said. None of the countries has confirmed this.