The Libyan army has imposed a no fly zone over Benghazi in a direct challenge to a retired general who has been using government aircraft and troops in an unauthorised campaign against Islamist groups.

Major General Khalifa Haftar, who lived in exile in the United States before returning home to lead ground forces in the 2011 NATO-backed uprising that toppled Muammar Gaddafi, heads what he calls a "National Army".

On Friday his paramilitary force, backed by warplanes and helicopters, pounded Islamist fighters in Libya's second biggest city, in clashes that killed at least 36 people and injured another 138.

Interim Prime Minister Abdullah al-Thinni denounced Haftar's forces as "outlaws" and called on all parties to observe restraint.

But earlier on Saturday, Haftar said he would continue his campaign to free Benghazi of "terrorist groups".

"The operation will continue until Benghazi is purged of terrorists," Haftar told Libya Awalan television.

Evacuation call

Armed forces chief of staff Abdessalam Hadallah al-Salihin denied any army involvement in the Benghazi clashes, although he admitted that some officers and army units had defected to join Haftar.

Later, Haftar spokesman Colonel Mohammad al-Hegazi called on people living in the western Benghazi district of Guwersha and the south's Sidi Fradj to evacuate their homes.

He did not say if this was a prelude to attacks on those neighbourhoods, which are known to be bastions of the Islamists.

The army's high command then upped the ante by declaring all of Benghazi and its suburbs a "no fly zone until further notice," the state-run LANA news agency said.

"All military planes flying over the city will be shot down by army units... and units of the revolutionaries (ex-rebels)," it said.

It was not clear if the army had the means to carry out its threat, which came as local sources said mediation was underway to try and prevent new fighting in the city.

Haftar had unleashed his forces on two former rebel Islamist groups, vowing to rid Benghazi of a "terrorist" scourge, just weeks after Tripoli acknowledged for the first time the existence of "terrorist groups" in Libya and said it was mobilising against them.

Haftar's forces focused in particular on Ansar Sharia, an organisation designated by the US as a "terrorist" group.

Airport closed

The fighting had initially subsided by Friday afternoon, an AFP journalist said, as witnesses reported that Haftar's forces were pulling back.

Air traffic was suspended in Benghazi during the day and an official said the city's airport would be closed for 24 hours for security reasons.

Libyans appeared divided about the fighting.

Some believe Haftar's operation is a prelude to a military coup and his objective is to seize power.

Others see him as a strongman who could rid Libya of extremism, a task the central authorities have been unable to achieve despite pledging to do so.

Haftar himself comes from eastern Libya, but returned from the US after the Arab Spring swept eastwards from Tunisia.