A court in Libya has sentenced Saif al-Islam Gaddafi, son of deposed leader Col Muammar Gaddafi, and eight others to death over war crimes linked to the 2011 revolution.
More than 30 close associates of Col Gaddafi were tried for suppressing peaceful protests during the uprising.
Saif al-Islam was not in court, but has previously appeared via video link.
He is being held by a former rebel group from the town of Zintan that refuses to hand him over.
A Zintani source indicated to the BBC that they would not execute him or hand him over to the court.
'Until the bitter end'
Former head of intelligence for the Gaddafi regime, Abdullah al-Senussi, is among those also facing death by firing squad, as is former PM Baghdadi al-Mahmoudi.
They have the right to appeal against their sentences within 60 days.
In the years before the uprising, Saif al-Islam was known for trying to introduce political and economic reforms, says the BBC's North African correspondent Rana Jawad.
"But as people called for the fall of his father's rule - he stood by him till the bitter end," she added.
He is also wanted by the International Criminal Court on charges of war crimes and crimes against humanity.
Prosecutors say that he was part of his father's plans to "quell, by all means, the civilian demonstrations against the Gaddafi regime".
Libya's rival power bases
Eight other ex-officials received life sentences and seven were given jail terms of 12 years each, said chief investigator Sadiq al-Sur. Four were acquitted.
The defendants were accused of incitement to violence and murdering protesters during the revolution that eventually toppled Col Gaddafi.
Since his death, Libya has been plagued by instability, and currently has no single government.
Instead two warring factions each claim to run the country. An internationally-recognised parliament is based in Tobruk, while the capital Tripoli is held by rivals Libya Dawn.
The trial, which opened last year, has been dogged by criticism from human rights agencies, who are concerned about the fairness of Libya's judicial system.
The United Nations human rights office said it was "deeply disturbed" by the sentences, while Human Rights Watch said justice for the victims could "only be delivered through fair and transparent proceedings".
Saif al-Islam's captors by James Reevell, BBC News
With the first news of Saif al-Islam's capture in 2011, I heard the sound of celebratory gunfire and car horns across Tripoli. Few could believe it had actually happened. But soon Libyans were mockingly waving their fingers as images of Saif al-Islam's severed finger surfaced on social media.
He was caught deep in Libya's southern desert and immediately flown north to the mountains. Hordes met his plane at Zintan's rudimentary airstrip before he was whisked to a secret prison somewhere in the town.
The town's fierce fighters were key to the overthrow of Col Gaddafi - and after the revolution they established themselves as one of the most powerful militias in the country, cementing this with the capture of Libya's most wanted man - Saif al-Islam.
His captors were proud of their catch and delighted to recount the story of what they claimed was an audacious ambush in the desert.
But even in these early days they were adamant that they would not hand him over to the official authorities - a promise that still holds true.
To them he was already a precious political commodity that could be used as a bargaining chip with Libya's newly formed government.