TRIPOLI, Libya — Moammar Gadhafi's son and onetime heir apparent was convicted and sentenced to death on Tuesday by a court in the Libyan capital, Tripoli, on charges of murder and inciting genocide during the country's 2011 uprising.

But Seif al-Islam Gadhafi is unlikely to face the firing squad anytime soon. The sentence was handed down in absentia because he remains in the hands of a militia in western Libya that has refused to hand him over for the past four years — yet another sign of the country's bitter fragmentation since his father's fall from power.

The uncertainty surrounding Seif al-Islam's fate underlines both the weakness of the courts and the general chaos this North African nation has descended into, split between rival militias and governments while being threatened by an affiliate of the extremist Islamic State group, which has benefited from the turmoil and captured some areas in Libya.

The same Tripoli court on Tuesday also sentenced to death eight other former regime officials, including former Libyan spy chief, Abdullah al-Senoussi, who is in custody in the Libyan capital, as well as foreign intelligence chief Abuzed Omar-Dorda and Gadhafi's former prime minister, Baghdadi al-Mahmoudi.

The rulings can be appealed, and a defense lawyer in the case, Ali Aldaa, said he would challenge it before the Libyan Supreme Court. Another lawyer, Hussien Al-Sherif, described the verdicts as "very harsh."

"We did not expect the sentences to be like this for the defendants, and there will be an appeal to the Supreme Court," he said.

In London, al-Senoussi's wife, Fatma Farkash, asserted that the Tripoli court didn't have the authority to hand down the death sentence.

"It was a big shock for me and my children. We were not expecting this. It was an ugly verdict," she said. "Libya doesn't have a functioning state, and it was a closed hearing."

U.S.-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 victims of the serious crimes committed during the 2011 uprising deserve justice, but that can only be delivered through fair and transparent proceedings," Stork said.

Other international organizations, including the U.N. High Commissioner for Human Rights and the Council of Europe, also condemned the verdict. The Council of Europe said the case should have been turned over to the International Criminal Court, which tried to extradite Seif al-Islam for trial at The Hague on charges of crimes against humanity, in part because of concerns that he could not receive a fair trial in Libya.

Libya has slid into chaos since the overthrow and killing of Gadhafi, who ruled the country for four decades. It is now bitterly divided between an elected parliament and government in the far eastern city of Tobruk, which has 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, Seif al-Islam has been held by a militia in Zintan, which is allied with the Tobruk-based government against the Tripoli one.

The court that convicted him is affiliated with the Tripoli-based government, as is the Supreme Court, which has in the past ruled that the internationally recognized government in Tobruk is illegitimate, raising questions over whether it is under pressure from the militias that dominate the capital.

A total of 38 Gadhafi-era figures were on trial but only 29 were present in court Tuesday. Four were acquitted, one was remanded to a psychiatric hospital, while the remaining defendants were handed sentences ranging from five years to life imprisonment.

The British-educated second-eldest of Gadhafi's seven sons, Seif al-Islam was the most prominent figure of his father's regime. He returned to Gadhafi's side and vigorously attempted to rally loyalists during the uprising. He was seized while trying to flee to neighboring Niger after rebel forces took Tripoli.

The rest of Seif al-Islam's family members who survived, including his mother, sister, two brothers and others, were granted asylum in Oman in 2012 and moved there from Algeria, where they found refuge during the civil war.

During the trial, Seif 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 to murder and rape.

Hundreds of militias in Libya are battling for power and turf in a lawless environment that has allowed human traffickers and kidnappers to flourish. Meanwhile, extremists returning from fighting in the Syrian civil war have created a local affiliate of the Islamic State group, taking territory and beheading captives.

The U.N. envoy for Libya, Bernardino Leon, 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 earlier this month.

Rohan reported from Cairo. Associated Press writer Martin Benedyk in London contributed to this report.

In this image made from AP video, former Libyan officials who served during Moammar Gadhafi's era sit in the defendants' cage during their trial for crimes committed during Libya's 2011 uprising in a courtroom in Tripoli, Libya, Tuesday, July 28, 2015. The court sentenced Gadhafi's son, Seif al-Islam Gadhafi, who was not present inside the courtroom, to death by firing squad after convicting him of murder and inciting genocide during the 2011 civil war. (AP Photo via AP video)

Think your friends should see this? Share it with them!

Story copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

Feedback, Corrections and Other Requests: AP welcomes feedback and comments from readers. Send an email to info@ap.org and it will be forwarded to the appropriate editor or reporter.