TRIPOLI (Reuters) - Heavy clashes erupted in the Libyan capital Tripoli on Friday, as armed groups aligned with the U.N.-backed government fought to fend off a major offensive by rival Islamist-leaning forces and militia fighters.

Loud explosions and heavy artillery fire could be heard across Tripoli from early morning. At least 28 people were killed in the violence and more than 120 wounded, according to health officials.

The U.N.-backed Government of National Accord (GNA) issued a statement blaming the attack on Khalifa Ghwell, the head of a self-declared, Islamist-leaning “national salvation government” that was set up in 2014, and Salah Badi, an allied militia leader.

It was unclear how much territory either side had gained. But late on Friday a spokesman for the judicial police said a GNA-aligned faction had gained control of the Al-Hadba prison, which holds several high profile inmates including one of former leader Muammar Gaddafi’s sons and his military intelligence chief.

“Tomorrow we’re going to move them to a safer place,” said the spokesman, Ahmed Abu Kraa.

Ghwell’s government has been largely displaced by the GNA, which arrived in Tripoli last year, but it continues draw on armed support, especially from the western city of Misrata.

The GNA has struggled to exert its authority in Tripoli and beyond, or rein in the militias that have held power on the ground in Libya since the country’s 2011 uprising that toppled Gaddafi.

A third government based in eastern Libya and aligned with military commander Khalifa Haftar has rejected the GNA.

“We call on the people of Tripoli to stand hand in hand with the Government of National Accord and its security apparatus to defeat the saboteurs,” the GNA said.

The clashes follow a period of relative calm in Tripoli since March, when GNA-aligned groups pushed rival factions back from central neighborhoods.

There have been rumors for weeks that a counter-attack was being planned under the name “Libya Pride”, which in Arabic is a play on “Libya Dawn”, the coalition of militias that brought the salvation government to power in Tripoli three years ago.

A Libya Pride Facebook page with 17,000 followers carried a post overnight announcing: “With Allah, we officially launch the operation of southern Tripoli.”

One GNA-aligned faction said “ideological gangs” had begun an attack “aiming to control the capital and put the country into a storm of violation and destabilization, in addition to increasing the suffering of citizens in the holy month of Ramadan”.

The fighting was concentrated in the Abu Salim, Salahedeen and Qasr Bin Ghashir districts. Large plumes of black smoke could be seen billowing above the city’s skyline. Shooting continued throughout Friday prayers.

“We have received calls from families who want to get out but unfortunately we can’t reach them because of the clashes,” one aid worker told Reuters.

A Reuters reporter saw tanks, armored vehicles and pickups mounted with anti-aircraft guns driving towards the battle from the north of the city.

Pictures posted on the internet also showed firemen trying to extinguish a blaze in an office building in central Tripoli belonging to Mellitah Oil and Gas, a joint venture between Libya's National Oil Corporation and Italy's Eni ENI.MI.

United Nations Libya envoy Martin Kobler condemned the violence in a statement and called for an immediate restoration of calm.