A Libyan court on Monday sentenced 17 people to death after finding them guilty of joining the Islamic State group and carrying out atrocities in its name, the prosecution said.
The Tripoli court also sentenced two people to life in prison and 14 others to lesser jail sentences, it said.
They had been found guilty of other IS-linked acts and of having "attacked the state and social peace" as well as "armed violence" in the western city of Sabratha and surroundings, it said in a statement.
Those on trial had killed a total of 53 people, "destroyed public buildings" and "disappeared dozens of people," it said. Their nationalities of those sentenced to death were not given.
Libya's collapse into violence after the revolt that toppled and killed dictator Muammar Gaddafi in 2011 left a power vacuum that was filled by a multitude of armed groups, including IS.
The extremist group used Gaddafi's home town of Sirte as its base from mid-2015 until it was ousted the following year.
Some militants were killed, others captured and some took refuge in the country's vast desert or in the cities of western Libya.
IS fighters also briefly seized Sabratha in February 2016, but were quickly ousted by government troops.
Libya in 2010 voted against a UN General Assembly resolution calling for a global moratorium on the death penalty, but does not publish reliable figures on how many such penalties it carries out.