Rival factions wrestling for control in a divided Libya are plunging the country into further chaos, as a UN-brokered government struggles to bring stability to its people.

In a quick turn of events this week, Libyan military commander Khalifa Haftar met Russian officials in an effort to secure crucial military support that would pave the way for his control of the North African country.

Haftar visited a Russian aircraft carrier off the coast of Tobruk from where he held a video conference with Russian defence minister Sergey Shoigu. Italian State TV RAI reported that Haftar signed an agreement whereby Russia would build two military bases near Tobruk and Benghazi.

Russian state media did not mention the agreement, but confirmed that Russia would get a foothold in the south of the Mediterranean. The move would also step up the foreign presence in the Eastern part of Libya, where Emirati and French air forces have been reportedly operating since March from the Al-Khadim Airport in the city of Marj, Haftar's headquarters.

General Haftar refuses to acknowledge the political authority of the UN-sponsored Presidential Council led by Fayez al-Sarraj and has engaged in a power struggle with Tripoli that has strongly weakened prospects for a unification of the country.

OPINION: In Libya, Britain's ignorance triumphed over caution

Meanwhile, on Thursday, Prime Minister Sarraj flew to Egypt, Haftar's main ally along with Russia and the UAE, in an attempt to avert a further worsening of the political stalemate, which is resulting in an unprecedented economic crisis.

However, Sarraj had to make a hasty return to Tripoli, where supporters of Khalifa Ghwell, a former prime minister in the unrecognised National Salvation Government , staged a second tentative coup on Wednesday. Ghwell had already tried to seize power last October to flag up the growing discontent over Sarraj's management of the political crisis.

Ghwell's demonstrative act took place a day after Italy reopened its diplomatic mission in Libya, in a symbolic display of political support for the crippled Government of National Accord (GNA) presided over by Sarraj, whose authority has been progressively eroding when the Tobruk-based House of Representatives (HoR), under the direct influence of General Haftar, has refused twice to endorse Sarraj's proposed list of ministers.

The HoR, which under a UN deal is set to become Libya's legitimate parliament, is endorsing a different governing body in the east of the country led by Abdullah al-Thinni, thus leaving Sarraj's executive in a risky political limbo.

The future of the UN-led initiative, which resulted in the Libyan Political Agreement and was signed by the Libyan factions in December 2015, now hangs in the balance. The success of the deal inevitably depends on Haftar's next moves and the extent of Russia's involvement in Libya, analysts say.

"If Haftar doesn't agree to the UN plan, there is no way out of the crisis. His role is key," said Arturo Varvelli, a Libya specialist at the Institute of International Political Studies. "The question is whether the general aims at playing a role within the GNA or at becoming Libya's new leader. I am afraid he is going for the second option. He mistakenly believes he would be able to govern the entire country, but militias in Misrata and Tripoli will never consent."

In a display of strategic sagacity, Haftar has waited for Sarraj to progressively erode his authority in Tripoli while avoiding engaging militarily with rival militias in Misrata, who support Sarraj and the GNA. Misrata forces have been occupied throughout 2016 in the war against the ISIL in Sirte, which they liberated in December after suffering extensive casualties.

In the meantime, Haftar has consolidated his role in Cyrenaica. He has successfully contained jihadists from the Revolutionary Shura Council in Benghazi and in September he occupied the oil terminals in the east of the country, after dislodging military units of the Petroleum Facilities Guard and their commander Ibrahim Jadhran, an ally of the GNA.

The seizure of the so-called Oil Crescent has been a major blow to the GNA, for which crude oil exports represent a vital source of revenues. The move has further shifted the balance of power in favour of Haftar, who all along has worked on strengthening his ties with foreign powers, above all Russia.

Libya represents an interesting opportunity for Russia's geopolitical ambitions. The Kremlin is taking advantage of the political void left by the American administration and is stretching its arm in the Mediterranean. Arturo Varvelli, a Libya specialist at the Institute of International Political Studies

"Libya represents an interesting opportunity for Russia's geopolitical ambitions. The Kremlin is taking advantage of the political void left by the American administration and is stretching its arm in the Mediterranean," Varvelli told Al Jazeera.

In an interview with the Italian Il Corriere della Sera, Haftar said Russia granted him help for an end to the UN arms embargo on Libya and could supply him with weapons, although the Russians haven't confirmed Haftar's claims.

"We were told arms can arrive only after the end of the embargo and [President] Putin has promised to help lift it," Haftar said.

Since 2011, the UN embargo prohibits the transfer of weapons into Libya. Only the legitimate government of the National Accord can receive weapons upon the approval of a UN Security Council committee.

"It is unlikely Russia will try to lift the embargo, considering Europe's determination to maintain it in such a dangerous context," said Mattia Toaldo, senior policy fellow at the European Council for Foreign Relations. "I don't believe Moscow is seeking a direct intervention in Libya in the same way as in Syria. In the next few months, the Kremlin will keep exerting its influence from the outside," Toaldo explained.

"However, until Haftar will believe he has the unconditional support of Russia, and possibly of the Trump administration, he won't have any interest in taking part in the ongoing political negotiations."

READ MORE: In Libya 'there are no winners today'

Toaldo said the UN-brokered deal is in a bad shape but still offers a viable negotiating framework. "The Government of National Accord is in a bad situation but the political project isn't dead. The deal will be reformed but won't be abandoned," he told Al Jazeera.

There is an intense activity in Egypt and Libya's neighbouring countries to find an agreement over a reform of the UN power-sharing agreement. The international community is still keen on establishing a comprehensive governing body that would include the Islamic factions and where military power would be submitted to political authority.

On the other end, General Haftar, backed by Egypt, is seeking to exclude the Islamists from the political negotiations and pursues the independence of the military power from the government.

However, a reform of the peace deal that would acknowledge heavyweights and main actors on the ground, above all Haftar and the Misrata forces, is inevitable, analysts say. Sarraj may not be necessarily part of a future picture. His incapability to manage the crisis has proven fatal and the UN may not want to salvage him against all odds.

"In 2017, we may see this political stalemate continue, while Haftar will slowly advance into the west and south of the country. In the meantime, the living conditions in the country would further deteriorate," Toaldo said.

The population discontent is rampant against the GNA and Sarraj's management of the economic crisis owing to the daily water and power cuts, shortage of cash and lack of basic services. Food shortages have resulted in a thriving black market, driving up the price of food by 31 percent in the first half of 2016.

The combination of inflation, devaluation of the dinar in the black market and the increased cost of basic goods and commodities has led to significantly reduced purchasing power for the Libyan people.

According to the UN Office for the Coordination of Humanitarian Assistance (UNOCHA), at least 2.4 million people out of a total population of 6.4 million are in urgent need of humanitarian assistance.

The UN agency said that in 2016, Libya registered the fourth consecutive year of decline in oil production, on which government revenues depend. In the first half of 2016, the country produced an average 350,000 barrels per day, almost 20 percent less than in the previous year.

The year 2016 has ended with a GDP budget deficit of more than 60 percent, while foreign reserves have been rapidly depleting, halving from $107.6bn in 2013 to an estimated $43bn in 2016.

"The failure of public financial administration continues with the government unable to come to an agreement on a national budget, a plan or a system to provide for the population," said a recently published UNOCHA country report.

"While funds are being allocated [including most recently the announcement from the Central Bank on the allocation of US7.8bn] from the contingency budget to the Presidential Council for energy, security, health and salaries, it is not clear how these funds will be distributed and if they will reach people in need."

Corruption is widespread, with stakeholders at multiple levels taking advantage of financial mismanagement throughout the country, the reports said.

READ MORE: The ghosts of Gaddafi

Building on the population discontent, last week, supporters of Ghwell, the former prime minister of the Salvation Government, stormed some empty ministerial buildings in the capital, Tripoli. Ghwell's attempt seems aimed to reinforce the perception of Sarraj's vulnerability as well as the volatility of the front supporting the GNA.

"The security situation in the capital remains fragile as usual," said Giuseppe Perrone, the Italian ambassador to Tripoli. Italy reopened its embassy on January 10 in an attempt to break the international isolation that Libyans are living in, Perrone said.

"Until security will be managed by different rival factions, the situation will not change. In this contest, the ongoing effort to create a presidential guard that would serve the institutions and grant their safety is very important," the ambassador said.

Italy has promised to provide logistical and training support to Libya's coastguard and military forces to enhance border control and migrant flows. But the plan is far-fetched as long as Libya's authorities fail to exert any control over the country's territory.

Libya is the primary route for refugees and migrants from Africa and the Middle East with Italy their first destination. In 2016 some 181,000 refugees arrived on the Italian coasts, a 20 percent increase from 2015.

The embassy reopening has been harshly criticised by the Tobruk-backed government of Abdullah al-Thinni which branded it as "a military occupation".

Meanwhile, General Haftar criticised Italy's presence in Misrata, where Italians set up a military hospital and invited foreign countries "to stay out of Libya's affairs".