It is unlikely, however, the sentence against Saif al-Islam Gaddafi will be carried out soon as a militia in western Libya has refused to hand him over to the government for the past four years.

That uncertainty reflects the chaos still gripping the north African nation split between rival militias and governments while facing an affiliate of the extremist Islamic State group.

The Tripoli court sentenced to death eight others, including former Libyan spy chief Abdullah al-Senoussi, who is in their custody. Also sentenced to death were foreign intelligence chief Abuzed Omar-Dorda and Gaddafi's former prime minister Baghdadi al-Mahmoudi.

The rulings can be appealed and a defence lawyer in the case, Ali Aldaa, said he would challenge it before the Libyan Supreme Court.

The Tripoli-based top court has in the past ruled the Tobruk government as illegitimate, raising questions over whether it is under pressure from militias that dominate the city.

Only 29 of the 38 Gaddafi-era figures were present in court. Six others were sentenced to life in prison and four were cleared of charges.

The US-based Human Rights Watch said the trial was "undermined by serious due process violations" and called on the Libyan Supreme Court to independently review the verdict.

"This trial has been plagued by persistent, credible allegations of fair trial breaches that warrant independent and impartial judicial review," said Joe Stork, Human Rights Watch's deputy Middle East and North Africa director.

The Council of Europe said the case should have been turned over to the International Criminal Court at The Hague, which wants Saif al-Islam on charges of crimes against humanity.

Libya has slid into chaos since the overthrow and killing of Gaddafi, who ruled the country for four decades.

It is now bitterly divided between an elected parliament and government cornered in the country's east, with little power on the ground and an Islamist militia-backed government in the west that has seized Tripoli.

Since the end of the civil war, Saif al-Islam has been held by a militia in Zintan, which is allied with the Tobruk-based internationally-recognised government against the Tripoli one. The court that convicted him is affiliated with the Tripoli-based government.

During the trial, Saif al-Islam was accused of recruiting mercenaries who were given Libyan nationality, planning and carrying out attacks on civilian targets from the air, forming armed groups and shooting into crowds of demonstrators. Among the charges he was convicted of were incitement of murder and rape.

The UN envoy for Libya has urged the Islamist-led government in Tripoli to sign a peace deal that would establish a unity government. Members of the Tobruk government and regional leaders signed the unity accord in Morocco on July 11.