Fierce fighting saw fighters loyal to the rebel Libyan warlord Khalifa Haftar lose control of a key city to forces loyal to the United Nations backed government.

Taken at the beginning of his two-and-a-half month campaign to take control of Tripoli, Gharyan overlooks the mountain pass leading from the capital to the country’s oil and water-rich south.

Fighters loyal to the Government of National Accord (GNA) posted videos online of them inside the city earlier this week. They were seen with young men they captured and described as pro-Haftar fighters, as well as inside what they described as the rebel officer’s operations room.

Other footage purported to show forces of Mr Haftar’s Libyan National Army (LNA) in a convoy speeding out of the city. Reports from the hospital in the city circulating in local media described casualties from both sides as well as civilians hurt in the crossfire.

Osama Jweili, a native of the nearby mountain city of Zintan and commander of the western armed forces, claimed the GNA forces had taken "full control" of the town, though Mr Haftar’s forces claimed they had only seceded partial control.

On the frontlines in Libya’s latest war, a proxy battle is leaving the civilians to suffer

LNA commander Mabruk al-Ghazwi told local media that "sleeper cells" inside Gharyan had helped the government back forces.

He also conceded that Mr Hafar’s forces had moved their command-and-control facility to another location.

The surprise takeover of the town by the GNA could prove significant in the battle between the two sides, which had been mired in a stalemate. It could also serve as a disheartening blow to the United Arab Emirates, Saudi Arabia, Egypt, and Russia, which have backed Mr Haftar as a strongman who could restore order to Libya.

Turkey and Qatar have supplied the GNA with weapons and diplomatic and financial support.

Forces loyal to Mr Haftar who is based in eastern Libya, took control of Gharyan and turned it into a forward logistics and command-and-control hub when he launched his offensive on 4 April. The city, 90kilometers south of Tripoli, is a key gateway to both the capital and oil and gas fields to the south as well as the strategic Nafousa Mountain range of western Libya.

Support free-thinking journalism and attend Independent events

Mr Haftar’s offensive united fractious armed factions of western Libya behind the government of Prime Minister Fayez Serraj, and rallied a small measure of international support. A GNA spokesman said that eight airstrikes launched by western Libya’s fledgling air force had played a decisive role in the battle. A plane flown by an American pilot was shot down by Mr Haftar's forces last month.