They were accused of war crimes and suppressing peaceful protests during the revolution, a state prosecutor said in early June.
The trial had started in April 2014 before fighting between rival factions resulted in a power struggle with two governments competing for authority - one based in Tripoli and the other one in Tobruk in the east.
Saif al-Islam has been held since 2011 by a former rebel group in Zintan that opposes the Tripoli government.
Abdullah Senussi, the former intelligence chief, was among the former regime officials sentenced, as well as former prime minister Baghdadi Ali Mahmudi.


Salah al-Bakkoush, a Tripoli-based political analyst, said he did not expect the rulings to have strong resonance in Libya.
"Libyans in general have so many problems right now that many were not even following the trial," he told Al Jazeera. "Those who participated in the struggle against the regime of Gaddafi will be following and will be happy."
The International Criminal Court and other human rights organisations worry about the fairness of Libya's justice system although the North African country won the right in 2013 to try Gaddafi's former spy chief at home instead of at the ICC in The Hague.
Saif al-Islam's appearances before the court have been by video link and there have been none since May last year.
The Zintanis have refused to hand him over, saying they do not trust Tripoli to ensure he would not escape, but had agreed before the trial to have him tried in a court there.
Anas El-Gomati, a political analyst and director of Tripoli-based Sadeq Institute, said the trail had been "anything but legal and fair".
"I don't think the Zintanis will give him up," he told Al Jazeera. "They will not look for any solution going forward. These are two [administrations] who oppose each other and show no signs of trying to work together."
Gaddafi was killed in October 2011 after being captured by rebels during Libya's war. He had ruled Libya for four decades.