Official says 120 migrants were detained in the hangar, which was directly hit by the strike. (File)

Nearly 40 migrants were killed in an air strike Tuesday night on their detention centre in a Tripoli suburb blamed on Libyan strongman Khalifa Haftar, who has been trying for three months to seize the capital.

At least 70 were also wounded in the raid on Tajoura, an emergency services spokesman told AFP.

"This is a preliminary assessment and the toll could rise," said spokesman Osama Ali.

He said 120 migrants were detained in the hangar which was directly hit by the strike.

Bodies were strewn on the floor of the hangar, mixed with the belongings and blood-soaked clothes of migrants, an AFP photographer said.

Rescuers were searching for survivors under the rubble, while dozens of ambulances rushed to the scene.

In a statement, the internationally recognised national unity government (GNA) based in Tripoli denounced the attack as a "heinous crime" and blamed it on the "war criminal Khalifar Haftar".

Haftar, who controls much of eastern and southern Libya, in early April launched an offensive to take the capital.

The GNA accused pro-Haftar forces of having carried out a "premeditated" and "precise" attack on the migrant centre.

No one has so far claimed responsibility but pro-Haftar media reported Tuesday night a "series of air raids" in Tripoli and Tajoura.

The suburb of Tajoura, which has several military sites belonging to pro-GNA armed groups, is regularly targeted in air raids by Khalifa's forces.

Migrants 'at risk'

The UN refugee agency said it was "extremely concerned" at reports of the strikes on the migrant centre.

"UNHCR is extremely concerned about news of air strikes targeting Tajoura detention centre east of Tripoli, and accounts of refugees and migrants deceased," it tweeted.

"Civilians should never be a target."

Libya, wracked by chaos since the 2011 uprising against dictator Moamer Kadhafi, has become a major conduit for migrants seeking to reach Europe.

Rights groups say migrants face horrifying abuses in the North African country, which remains prey to a multitude of militias vying for control of the oil-rich country.

The plight of migrants has worsened since Haftar launched an offensive against Tripoli -- the seat of an internationally recognised unity government -- in early April.

Since then, fighting has killed more than 700 and wounded 4,000, while nearly 100,000 have been displaced, according to UN agencies.

Haftar's forces have pledged to intensify air strikes against their GNA rivals after losing a key town to unity government forces.

The two rival camps accuse each other of using foreign mercenaries and enjoying military support, especially air, from foreign powers.

The UN's mission in Libya has said around 3,500 migrants and refugees held in detention centres near the combat zone are at risk.

UN agencies and humanitarian organisations have regularly voiced their opposition to migrants arrested at sea being brought back to Libya, where they are "arbitrarily detained" or at the mercy of militias.

Despite chronic instability, Libya remains an important transit point for migrants fleeing conflict and instability in other parts of Africa and the Middle East.