The law renewed the mandate that came into force in January for another 18 months after a security and military agreement with the UN-backed Libyan administration in Tripoli.
The Turkish parliament has approved a motion calling for an extension to troop deployment in Libya for another 18 months.
While the governing Justice and Development (AK) Party, and the Nationalist Movement Party (MHP) backed the motion, the main opposition Republican People's Party (CHP), Peoples' Democratic Party (HDP), and Good (IYI) Party voted against it.
"There are threats from Libya to Turkey and the entire region, and if attacks resume again, Turkey's interests in the Mediterranean basin and North Africa will be adversely affected," the motion said.
It added that permanent peace, cease-fire which was agreed upon in October, and political dialogue in Libya is of great importance to Turkey.
"Turkey, within the Memorandum of Security and Military Cooperation signed with Libya, will continue to contribute to the training and consultancy support to Libya," it said.
The proposal was submitted by the presidency last week, in the light of a request by Libya's UN-recognised government for military assistance.
On November 27, Ankara and Tripoli signed a pact on military cooperation, as well as an agreement on maritime boundaries in the Eastern Mediterranean.
Since the ouster of late leader Muammar Gaddafi in 2011, two seats of power have emerged in Libya: one in eastern Libya mainly supported by Egypt and the United Arab Emirates, and another in Tripoli, which enjoys UN and international recognition.
Turkey sent its troops to the North African country on a year-long mandate in January.
The Turkish parliament approved another motion to extend the deployment of Turkish troops in Afghanistan for 18 months as part of NATO’s support mission in the war-torn country.
HDP lawmakers voted against the motion.
"Turkey, which has deep friendship and brotherhood ties with Afghanistan, has always backed the unity, integrity, and independence of Afghanistan," the motion read.
The legislation was put into effect on January 6, 2019, allowing the Turkish government to send troops to Afghanistan to support the NATO-led mission Resolute Support.
After ending the 17-year combat mission in Afghanistan in 2018, the mission has evolved into training and advising of the nascent Afghan security forces.
Around 12,000 foreign troops from 28 NATO allies and 14 other partner nations agreed to support the NATO mission in Afghanistan.
The legislation that was first passed in 2015 also grants the government authority to permit foreign army personnel to be transported to and from Afghanistan through Turkey.