Fears were mounting of renewed civil war in Libya after militias allied to the government in Tripoli captured scores of troops from a powerful rival force, and the UN secretary general, António Guterres, warned that he was ending a visit to the country “deeply concerned”.

Guterres suggested that a key meeting with eastern commander, Field Marshal Khalifa Haftar, had not resulted in assurances from the strongman leader to avoid an escalation of tensions.

“I leave Libya with a heavy heart and deeply concerned. I still hope it is possible to avoid a bloody confrontation in and around Tripoli. The UN is committed to facilitating a political solution and, whatever happens, the UN is committed to supporting the Libyan people,” Guterres said in a tweet late on Friday.

After Haftar ordered his forces to advance on the capital, militias supportive of the UN-backed government in Tripoli took prisoner 145 of his soldiers from a rival force advancing from the country’s east. Haftar’s men were captured in the town of Zawiya, west of Tripoli, along with 60 vehicles, a commander told Reuters.

The captured men are fighters in the self-styled Libyan National Army (LNA) of Haftar, who ordered the march on Tripoli on Thursday in a surprise move marking a dangerous escalation of a power struggle that has dragged on since the overthrow of Muammar Gaddafi in 2011.

Late on Friday the UN security council called on Haftar’s troops to halt all military movements and asked all sides to de-escalate. “There can be no military solution to the conflict,” said the German ambassador to the UN, Christoph Heusgen, the current council president.

Libya is riven between two rival factions, one broadly supporting Haftar in the east and another based in Tripoli in the west, including the UN-backed government led by Fayez al-Sarraj.

LNA forces took Gharyan, about 50 miles (80km) south of Tripoli, but they failed to take a checkpoint about 18 miles west of the capital in an attempt to close the coastal road to Tunisia. Pro-government militiamen from the coastal town of Zawiya, west of Tripoli, retook the checkpoint after what was described as a short exchange of fire. Pictures on social media showed scores of captured soldiers huddled together inside corridors, but the pictures could not be verified.

The assault to repel Haftar’s troops was mounted by forces coming from Tripoli and the coastal town of Misrata.

Libyan strongman orders troops to march on Tripoli Read more

After advances across the south of the country in recent months, Haftar triggered fears of civil war by vowing to rid the capital of terrorists.

In a bid to avert full-scale war, Guterres met Haftar in Benghazi on Friday. Guterres, who has been in Tripoli this week to help organise a national reconciliation conference planned for later this month, spent Thursday night in the heavily fortified UN compound in a Tripoli suburb, before flying to Benghazi. He also went to Tobruk, another eastern city, to meet lawmakers in the House of Representatives, which is also allied to Haftar.

The UN chief was originally visiting to promote a painstakingly brokered national reconciliation conference due to be held in town of Ghadames in a fortnight’s time. The UN sees the conference as a chance to end the institutional divisions between east and west, as well as pave the way for holding presidential and parliamentary elections at the end of the year.

Haftar’s assault may have been an attempt to present the conference with a fait accompli, forcing the divided country to accept him as de facto ruler with effective military control of a future unified civilian government.

The UN special envoy, Ghassan Salamé, at Britain’s request, is due to hold a closed-door emergency session of the UN security council in New York. A joint statement from the US, Italy, France, the UK and the United Arab Emirates on Thursday urged all sides to show restraint, without singling out Haftar for escalating the dispute.

There were calls for sanctions to be imposed on Haftar if he refused to relent, but the leader has enjoyed diplomatic and military support from Egypt and the UAE. Russia insists that it is not backing his assault.

G7 foreign ministers meeting in France called for all sides to show restraint, but held back from identifying Haftar as the aggressor. Instead, in an indirect reference to the LNA, the G7 called on “all involved parties to immediately halt all military activity and movements toward Tripoli, which are hindering prospects for the UN-led political process, putting civilians in danger, and prolonging the suffering of the Libyan people”.

France and Italy have long vied for influence in the oil-rich country, and have major energy installations.

Since the fall of Gaddafi in 2011, Libya has slid into chaos and frequent spasms of violence. Successive UN-led efforts to unify Libya’s key institutions, including the central bank and political bodies, have failed, and the country’s major oil installations have frequently been held to ransom by a variety of militia groups.

Across many of the towns in Libya’s west, there would be deep resistance to Haftar or any effort to impose military rule, partly because they would fear reprisals by Haftar forces and partly because they do not want to return to the authoritarian rule of the Gaddafi era.

Haftar’s LNA is in reality an amalgam of militias with little unified ideology, including some Salafist forces, which he is nominally determined to eradicate.

Tarek Megerisi, Libyan analyst at the European Council on foreign relations, questioned Haftar’s strength, and claimed the UN was culpable in failing to do more earlier to force him to hold back.

“Haftar’s expansions to date have relied on coopting new local forces into the LNA franchise in what appears to be the military equivalent of a Ponzi scheme,” Megerisi said. “Keeping the LNA functional requires continuous expansion and income that is driven towards the operation’s core and leadership. At this point, his forces are overextended, his finances stretched, and if he’s forced to fight, he may be more fragile than many realise. Indeed, his recent escalation was, in part, driven by these vulnerabilities and his need for quick success.”

Associated Press and Reuters contributed to this report