A military offensive by a Libyan warlord against the country’s capital has done what years of negotiations and talks have failed to do – unite the country’s powerful western militias in an all-out effort to defend Tripoli.

Already at least 41 people have been killed and dozens more injured in clashes inside and outside of the capital, as the UN and EU struggled to put an end to the conflict that has pitted the country’s two main armed alliances against each other for control of the city of 1.2 million.

The UN said Monday that more than 2,800 people had been displaced by the fighting, which has blocked emergency services and damaged power lines.

Reports emerged that airstrikes had hit Mitiga International airport, the only aviation gateway into the capital.

A small contingent of US forces, focused on monitoring Isis, and Indian peacekeepers evacuated western Libya over the weekend as the fighting escalated.

“Libyans do not need any more fighting among themselves,” Federica Mogherini, foreign policy chief for the EU said on Monday.

“Libyans need dialogue and political agreement among themselves.”

In pictures: Isis' Libyan stronghold of Sirte Show all 10 1 /10 In pictures: Isis' Libyan stronghold of Sirte In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Isis fighters parade through in Sirte in 2015 In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Islamic State (IS) group jihadists on the outskirts of Libya's western city of Sirte AFP/Getty In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte A photo of a billboard in Sirte, Libya, listing seven rules for women's clothing, saying they must be loose-fitting and undecorated HRW/social media In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Isis militants process down a street in the coastal city of Sirte in Libya this week; the group has heralded Libya as its ‘strategic gateway’ to attack Europe AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte An Isis lecture on Sharia at the Ouagadougou complex in Sirte, Libya, in 2016. HRW/social media In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte A sign reading "The city of Sirte, under the shadow of Sharia" as smoke rises in the background while forces aligned with Libya's new unity government advance on the eastern and southern outskirts of the Islamic State stronghold of Sirte on 9 June. Reuters In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Fighters loyal to Libya's GNA prepare to launch attacks against Isis as they continue their resistance on the outskirts of the western city of Sirte Getty In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Forces loyal to Libya's UN-backed unity government are seen during clashes with jihadists of the Islamic State (IS) on the western outskirts of Sirte on June 2, 2016. AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Forces loyal to Libya's UN-backed unity government fire during clashes with Isis around 14 miles west of Sirte on June 2, 2016. AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Libya

Khalifa Haftar, the self-declared field marshal of an armed force backed by Persian Gulf monarchies and Russia, declared war on the militias controlling the capital four days ago, launching a surprise offensive hyped by sympathetic social media accounts and pan-Arab television channels.

“It was a shock that he decided to march on Tripoli,” said Hassan al-Houny, a chief advisor to Libya’s recognised prime minister, Faiez Serraj, whose government is anchored in Tripoli and was planning on attending 14 April peace talks with Mr Haftar.

“Then suddenly he decided to attack the capital,” he told The Independent from Mr Serraj’s offices.

But an umbrella group of militias from Tripoli and powerful armed forces from Misurata and Zintan – that had long been wary of each other – have rushed to the capital’s aid, vowing to defend Mr Serraj’s UN-backed government against Mr Haftar.

Several of the militias in Zintan, a city in the country’s western mountains often at odds with Misurata, have even vowed to take the fight to Mr Haftar in the east, where he is headquartered.

“Unexpectedly this united the western militias,” said Emad Badi, a London-based Libya expert at the Middle East Institute, in Washington.

“What we’re seeing is the largest mobilisation in the west of Libya since 2014, if not 2011. A big chunk of forces in western Libya see Haftar as an existential threat.”

Mr Haftar’s latest gambit for the capital, launched as UN secretary general, Antonio Guterres, was in Tripoli ahead of peace talks scheduled later this month, might have amounted to overreach.

His forces have vowed they will not stop until they have “cleansed” Tripoli of militias, and signalled there was no hope of rapprochement with the recognised authorities.

“Any man carrying a weapon in his hand against us is a target. If he hands over his weapons or stays at home, he will be safe,” Mohamed Ghuneim, a spokesman for Mr Haftar told The Independent.

Some of Mr Haftar’s allies, including Egypt, France, and the UAE, appeared to have been taken aback, though the Kremlin and some of its allies appear eager to support him.

The UN Security Council in a statement on Friday identified his forces as the aggressors, calling for an end to the hostilities.

In a rare statement identifying him by name, US secretary of state, Mike Pompeo, on Sunday also called on Mr Haftar to step back: “We oppose the military offensive by Khalifa Haftar’s forces and urge the immediate halt to these military operations against the Libyan capital,” he said.

Mr Haftar, a former colonel in the armed forces of Muammar Gaddafi who spent decades in exile in Virginia, assembled a collection of militias to restore to the country in 2014.

He has since conquered much of eastern Libya, including the second largest city Benghazi. He recently succeeded in taking control of chaotic southern cities near the country’s oil installations.

Less than two weeks ago he visited Saudi Arabia’s King Salman, and has been receiving Saudi social media support for his military campaign.

But some wonder whether Mr Haftar has miscalculated. It wouldn’t be the first time.

He got over-excited and ordered this full-scale offensive thinking it wouldn’t trigger a larger mobilisation Emad London-based Libya expert at the Middle East Institute

He vowed in 2014 to take control of Benghazi from Islamist militias within weeks – it took three years and cost near-complete destruction of much of the city.

Many of his victories have been the result of militias quickly flipping sides rather than risk casualties.

Some analysts speculated that this time, Mr Haftar aimed to seize a few towns outside of Tripoli and promote them across his television outlets to shock the capital into a quick submission, or at least to bolster his position ahead of now-scuttled UN-brokered talks in the western city of Ghadames.

“He got over-excited and ordered this full-scale offensive thinking it wouldn’t trigger a larger mobilisation,” said Mr Badi.

“He was gambling on getting more forces on his side. Now there’s no advantage for Haftar here militarily speaking, aside from the element of surprise that has since faded.”

Misurata, Libya’s third city, boasts battle-hardened and well-equipped militias that are seen as among the country’s most powerful armed forces.

“We will stop at nothing, we will go right to the end, annihilating his every attempt at aggression,” Ahmad Maitiq, deputy prime minister of the Tripoli government, told the Italian daily La Stampa on Monday.

“Haftar must stop and go back to where he came from, otherwise we will force him to do so.”

Two armed forces mobilise in Libya

Mr Haftar’s offensive has also elevated the stature of Mr Serraj, who is blessed by the UN as an interim leader but lacks a loyal armed force. He has been attempting for months to coax Mr Haftar into a deal that would stitch back together Libya’s fragmented government.

Militias in the Libyan capital had reluctantly backed Mr Serraj in a gamble to win international legitimacy, but now say they are wholeheartedly behind him.

“We have the duty to defend the capital from any illegitimate military movements,” Ahmed Bin Salam, spokesman for Tripoli Special Deterrent Forces, told The Independent.

Inside Tripoli however, there was fear.

“People are afraid that Tripoli will become another Benghazi,” said Hana, a 33-year-old director of an international firm inside Tripoli.

While Mr Haftar enjoys some support, he also has many enemies, and others who despite both the militias running the city but also fear the type of military regime the self-declared field marshal would implement.

“The cities he is controlling are suffering the same issues as the cities he’s not controlling: shortage of cash, electricity and no jobs,” said Hana.

We have the duty to defend the capital from any illegitimate military movements Ahmed Bin Salam, spokesman for Tripoli Special Deterrent Forces

Yet many residents took the conflict in stride, especially after word spread that Misurata would be defending the city.

According to Tunisian state radio, there was no sign of increased traffic at the land border at Ras Ajdir, which has for eight years been the gateway out of Libya for residents fleeing conflict.

Gone are the days when residents of Tripoli rushed to the markets to stock up on food and supplies ahead of armed conflict engulfing the city.

After eight years of near-continuous battles and skirmishes that have seen the capital’s airport completely destroyed, heavy gunfire rattle the nights and thick plumes of black smoke rise up over the city of 1.2 million, ordinary people are immune to panic.