Tripoli: At least 28 people were killed and nearly 130 wounded in fierce clashes on Friday between forces loyal to the UN-backed unity government and rival militiamen, the health ministry said.

The city has been gripped by a power struggle between dozens of militias since a Nato-backed uprising toppled longtime dictator Muammar Gaddafi in 2011.

Health ministry spokesman Anwar Frajallah was not able to say if civilians were among the casualties, as he gave a provisional toll of 28 dead and 128 wounded.

Hashem Bishr, a security official for the Government of National Accord (GNA), separately gave a toll of 23 loyalist forces killed and more than 29 wounded.

Medical sources were not immediately available to confirm the figures.

Elsewhere in the capital, an armed group loyal to the GNA attacked a prison holding senior officials of the former regime of dead dictator Muammar Gaddafi including his ex-premier and intelligence chief, a judicial source said.

Guards at Al Hadhba jail were forced to withdraw after the attack, said the source requesting anonymity, adding that two guards were killed.

Inmates there include Gaddafi’s last prime minister Baghdadi Al Mahmoudi and his former intelligence chief, Abdullah Senussi. Both were condemned to death in 2015.

Of the earlier fighting, an official at a Tripoli hospital gave a “provisional” toll of five dead and several wounded, including civilians.

A militia loyal to the unity government, the Abu Slim Deterrence Force, said on its Facebook page that it lost five fighters, but it was unclear if they were included in the hospital toll.

The fighting broke out in residential neighbourhoods.

AFP journalists heard explosions and artillery fire rock the Abu Slim, Al Hadhba and Salaheddin districts in the south of the city.

The UN Libya envoy Martin Kobler issued an appeal for a halt to the fighting.

“Voices of reason should prevail for the benefit of the country,” he said. “Political aims must not be pursued through violence. Civilians must be protected.”

Witnesses said tanks had been deployed in the fighting.

British ambassador Peter Millett tweeted that he could hear explosions and artillery in south Tripoli.

He condemned “action by these militias who threaten security” ahead of the Muslim holy month of Ramadan, which begins on Saturday in Libya.

Groups hostile to the GNA said they had attacked loyalist forces.

By late afternoon the fighting had subsided, but intermittent gunfire could still be heard in several areas of the capital.

The fighting started around a complex of luxury villas that until March had served as the headquarters of militias loyal to former prime minister Khalifa Ghweil.

Ghweil was ousted from power when the GNA took office in March 2016, and has refused to recognise the new administration.

Loyalist forces seized the villas in four days of intense fighting in March that saw them expand their control over the capital.

Tripoli had been relatively calm since, but dozens of armed groups still operate there — including several that support Ghweil.

The GNA has won the support of various militias since it took office in March last year, but several parts of Tripoli remain beyond its control.

Relying on militia support and pitted against a rival administration in the east, the GNA has struggled to assert its authority.

In a statement on Friday, the GNA blamed Ghweil and Salah Badi, both leaders of the Fajr Libya coalition of militias which took power in Tripoli in 2014, and vowed to “retaliate mercilessly”.

They “have exceeded all limits ... Nothing stops them, not faith, not law, not custom and not morals,” it said.

“This is their gift to the people for the month of Ramadan”, the statement said.