ISTANBUL — Turkey's parliament voted Thursday to approve a request by President Recep Tayyip Erdogan to send military forces to Libya, setting the stage for deeper Turkish involvement in a civil war that has grown more incendiary as foreign powers have intervened.

Erdogan’s government has already provided military advice and materiel, including weaponized drones, to Libya’s internationally recognized government. Turkey’s proposal to ratchet up its support comes as its Libyan allies are trying to fend off an offensive against Tripoli, the capital, by forces loyal to a rival government based in eastern Libya.

Ankara said it sought the troop authorization after the Tripoli government asked for support and also to protect Turkish interests in Libya. But the move — which deepens a standoff between Turkey and its rivals in the Middle East — shows how easily regional feuds and a competition for influence in the Mediterranean Sea are fostering the violence in Libya, a country of 6 million people that has been riven by armed conflict for the better part of a decade.

Its backing of the Tripoli-based government has pitted Turkey against Egypt and the United Arab Emirates, whose governments have provided military support to Khalifa Hifter, the commander of the eastern Libyan forces. Hundreds of Russian mercenaries backed by the Kremlin have also joined Hifter’s campaign to capture the Libyan capital.

Turkey and the Tripoli government also recently signed an agreement to carve out gas drilling rights in the Mediterranean — angering Egypt, Cyprus, Greece and the European Union, which see the deal as an effort to restrict their ability to drill.

Egypt, which shares a border with Libya, swiftly condemned Turkey’s parliamentary vote Thursday, saying Ankara’s “interference threatens Arab national security in general and Egypt’s national security in particular,” according to a foreign ministry statement.

President Trump, in a phone call with Erdogan after the vote Thursday, “pointed out that foreign interference is complicating the situation in Libya,” according to a White House readout of the call. The Trump administration has sent jumbled signals about its goals in Libya — at times seeming to endorse Hifter’s offensive, while more recently calling on him to end his march on the Libyan capital.

Deeper involvement in Libya also carries risks for Erdogan, who has pursued more-aggressive policies abroad in part to rally nationalist supporters at home, analysts said. His proposal to deploy troops to Libya came three months after Turkey launched a military invasion against U.S.-backed Kurdish fighters in northern Syria that drew international condemnation but was broadly popular domestically.

On Thursday, Turkish opposition politicians were openly critical of the government’s latest military plans. Ahmet Unal Cevikoz, the deputy chairman of the Republican People’s Party, Turkey’s main opposition party, accused the state of launching a military operation without articulating the national interest in such a move.

“You are throwing your soldiers in the middle of a territory that is life-threatening in a foreign country where a civil war reigns,” he said during the parliamentary debate. The scope and duration of the Libyan operation, he added, “are left open, vague and uncertain.”

Turkish officials, including the vice president, have suggested that the sending of Turkish troops could be avoided if Hifter’s offensive was called off. Fahrettin Altun, a spokesman for Erdogan, insisted after the parliamentary vote that Turkey was defending its “rights and interests” in the Mediterranean, even as he appeared to play down worries about a military escalation.

“No regional powers need take offense by it but work with us!” he wrote on Twitter. “. . . We will prevent any effort to exploit the conflict in the region. At the same time, we are also ready to cooperate on establishing stability!”

His remarks were widely seen as part of Turkey’s ongoing dialogue with Russia, as the two putative partners haggle over conflicts in a region where both countries have intervened, in Libya as well as Syria.

Turkey’s threat to send troops to Libya — which would put Turkish troops on the opposite side of the battle lines from Russian-backed fighters — appeared aimed at providing Ankara with negotiating leverage just days ahead of a planned visit to Turkey by Russian President Vladi­mir Putin, analysts said.

Erdogan’s effort to persuade Moscow to reverse support for Hifter had been strengthened after Turkey’s threats of military action, Tarek Megerisi and Asli Aydintasbas wrote in an essay last month for the European Council on Foreign Relations.

“For the time being there is an understanding that Turkey and Russia will not cross swords within Libya, but they are laying the groundwork for a more comprehensive deal,” they wrote.

Heba Farouk Mahfouz and Sudarsan Raghavan in Cairo contributed to this report.