MOSCOW — When the U.S. military said that more than a dozen Russian military planes had arrived in Libya last month — with identifying emblems painted over for apparent deniability — the Pentagon accused President Vladimir Putin of trying to tip the balance in a civil war, as he did in Syria.

And, as in Syria, Russia’s interests in Libya include expanding its military and political reach in the Middle East and Mediterranean — while also waging a proxy battle with rivals such as Turkey.

Russia is eager for oil and construction contracts in Libya. But the Kremlin’s strategic objective, U.S. military officials believe, is to secure military bases on Europe’s southern flank.

Which side does Russia back?

Russia and Turkey back opposing sides in the Libyan civil war, part of a competition for future energy contracts and other deals worth billions in the oil-rich country.

Russia’s ally in Libya, rebel commander Khalifa Hifter, has suffered a string of defeats in recent months as his militias tried to oust the U.N.-backed government in Tripoli so he could install himself as Libya’s ruler.

On Friday, forces of the Tripoli government — supported by Turkey and others — seized control of Tarhuna, the last stronghold for Hifter’s fighters in the country’s west. The recapture of the city, about 40 miles southeast of Tripoli, could mark a final blow to Hifter’s siege of Tripoli and his bid to expand beyond his power base in eastern Libya.

In Cairo on Saturday, Hifter accepted a unilateral cease-fire and political initiative backed by Russia and Egypt, underscoring his weakened military position.

The cease-fire would begin Monday, said Egyptian President Abdel Fatah al-Sissi at a ceremony attended by Hifter and Aguila Saleh, the speaker of parliament for the Tripoli government. But it remains unclear whether the U.N.-supported government and its primary backer, Turkey, will accept the offer. Government forces were advancing on the coastal city of Sirte and other Hifter-controlled areas even as the Cairo talks were held.

Libya’s war has raged since NATO’s 2011 operation opened the way for rebel forces, which eventually tracked down and killed dictator Moammar Gaddafi. Russia has avoided a direct military presence in Libya — unlike in Syria, where Russia’s air force, navy and other units aided Moscow’s longtime ally, President Bashir al-Assad.

Instead, Russia last year deployed mercenaries to back Hifter, achieving its strategic objectives under the cloak of deniability. About 1,200 of the Russian fighters are reportedly from the Wagner Group, controlled by Yevgeniy Prigozhin, a businessman with close ties to the Kremlin. Putin has not denied the presence of Wagner Group mercenaries in Libya, but he also said in January that they did not represent Russia or its interests.

Moscow’s ambiguous policy in Libya — offering lip service to peace efforts while boosting its aid to Hifter with warplanes — risks deepening its confrontation with NATO-member Turkey.

Who else sides with Russia?

Russia is not the only foreign power interfering.

Hifter’s other backers include the United Arab Emirates, supplying advanced weapons including the Russian-made ­Pantsir S-1 air defense system and Chinese-made drones. Hifter also has support from Egypt, Saudi Arabia, Jordan, France and others. He even received a phone call of support from President Trump last year, although the U.S. State Department now calls Hifter an “illegitimate parallel entity.”

Turkey, Qatar and Italy are among those behind the U.N.-installed government.

“Russia wants a foothold in Libya, and that’s a fact,” said Russian military analyst Pavel Felgenhauer of the Jamestown Foundation, adding that it is not yet clear whether Putin plans a major Syria-style intervention.

“In Syria in 2015, there was a deliberate decision to begin a major operation to deploy forces,” Felgenhauer said. “Here, there are different opinions on how to proceed, and it’s not clear that there has been a decision to do in Libya what was done in Syria.”

He noted that pro-Kremlin websites and Russian TV have not been trying to “whip up public support” to intensify Russian involvement against Turkey and its allies in Libya. Putin also remains in close contact with Turkey’s president, Recep Tayyip Erdogan.

“That means there is no such political decision for a head-on collision at the moment,” Felgenhaur said.

Turkey, however, has ramped up its military aid to the U.N.-backed side, deploying attack drones to drive back Hifter’s forces. It also sent in up to 13,000 mercenaries, according to the Syrian Observatory for Human Rights, many of them Syrian fighters who were allied with Turkey against Assad.

What do the warplanes mean?

Russia is working with Syria to deploy Syrian fighters loyal to Assad on Hifter’s side, according to U.S. officials.

But the dispatch to Syria of at least 14 Russian MiG-29s and Su-24s is not likely to turn the conflict around, analysts predict.

Russia is playing a double game, according to analysts, encouraging diplomacy to try to establish a cease-fire and power-sharing deal, while sending in planes and mercenaries to shore up Hifter in the oil-rich east.

The planes and mercenaries are designed to cement Hifter’s military position and strengthen his bargaining power in negotiations, according to Russia analyst Samuel Ramani, doctoral candidate at Oxford University’s Department of Politics and International Relations.

Putin, who sees his role as rebuilding Russia’s status as a global power, is disdainful of Western outrage, given that NATO’s 2011 action cost Russia billions in contracts that had been signed with Gaddafi.

“Russia wants to show that it is standing up from its knees, it’s a great player in the Middle East and Russia is seeking a strongman in Libya,” said Russian defense analyst Alexander Golts.

Ramani said Russia’s goal was the de facto partition of Libya, giving it influence in the east.

“Now that Hifter is on the retreat, Russia’s use of air power can only at best stall Turkey and the GNA’s advance, so Russia is using its military operations to buy time to bring Hifter to the negotiating table,” he said, referring to the U.N.-backed Government of National Accord.

Russia’s goal, he added, is a three-way play: have sanctions lifted on Hifter’s forces, have him recognize the U.N.-installed government in Tripoli and “institutionalize Hifter’s hegemony over eastern Libya,” which could open the way for Russian energy deals.

Where does diplomacy stand?

In January, Putin and Erdogan tried to pressure Hifter and the leader of the U.N.-backed government, Fayez Serraj, to sign a cease-fire in Moscow. But Hifter humiliated Putin by refusing to sign. A later conference in Berlin failed to stop the fighting.

Felgenhauer said that Moscow is less interested in potential military bases than the pursuit of oil and reconstruction contracts. He said Russia already projects force west from its naval and air bases in Syria.

“For contracts, that requires a stable government. Since Hifter failed miserably for more than a year to take Tripoli and he can’t, that means it’s time to call it a day and it’s time to build some kind of power-sharing thing,” he said.

Since the U.S. military disclosed the apparent presence of the Russian warplanes in Libya, Russian Foreign Minister Sergei Lavrov has engaged in furious diplomatic footwork, pressing for a cease-fire and return to a political process.

Viktor Bondarev, chairman of the defense and security committee in Russia’s upper house of parliament, has denied that Russia sent warplanes to Libya.

“If there are any airplanes in Libya, they are Soviet, not Russian,” he said, adding they could have come from anywhere.

“Russia is essentially trying to assert its status as a great power, and its view is that a great power has to be at the table on the resolution of any major global issue,” said security analyst Mark Galeotti of University College London’s School of Slavonic and Eastern European Studies. “Nothing can be resolved without Russia being present and Russia’s interests being considered.”

Andrew S. Weiss, of the Carnegie Endowment for International Peace, said Putin is displaying an increasing appetite for risk, filling the vacuum left by the Trump administration.

“We’re seeing a much wider pattern of Russian opportunism across both the Middle East and other parts of the world far from Russia’s direct borders,” he said in video comments on the Carnegie website.

Sudarsan Raghavan in Cairo contributed to this report.