Libya's national assembly approved a law criminalizing torture and abductions on Tuesday as the government seeks to stamp its authority on a country awash with weapons where militias often have more power on the ground than state security forces.
Since the end of the 2011 uprising that toppled Moammar Gaddafi, Libya's new rulers have struggled to control myriad former rebel groups who refuse to lay down their arms and often take the law into their own hands and detain people.
Last week an armed group controlling a Tripoli prison stormed the justice ministry, an attack the justice minister said took place after the government ordered the group to hand control of the jail over to the authorities.
"Under this transitional justice law, it is a crime to torture prisoners, kidnap people and hold them in illegal detention centers," said an official from the general national congress' media office.
"This law aims to strengthen personal freedoms in the country."
International campaigns have identified armed militias as one of the biggest challenges to Libya's stability, and human rights organizations have voiced concern over abuses including arbitrary arrests, torture and deaths in detention.
Tensions have been rising between the government and militias in the last few weeks after the launch of a campaign aimed at dislodging armed groups from the public buildings they occupy in the capital, Tripoli.
The new law was welcomed by human rights activists despite acknowledging that ensuring it is respected will be a mammoth task given Libya's still weak courts and state security forces.
"This is a step in the right direction, it establishes basic human rights," Dao al-Mansouri Oun, a Libyan lawyer and human rights activist, told Reuters.
Earlier on Tuesday, Prime Minister Ali Zeidan's office confirmed the premier's top aide had been freed just over a week after unknown abductors snatched him from his car in a Tripoli suburb.