Dozens of Tunisians held in Libya by a militia forming part of an alliance ruling Tripoli have been freed, the Tunisian foreign ministry has announced.
The Tripoli-based government and the Tunisian foreign ministry said the Tunisians were held for verification of their identity papers.
The Tunisian consul in Tripoli has previously said they were apparently taken as bargaining chips for a Libyan militia commander arrested in Tunis.
"All the Tunisians being held in Libya have been freed. The final group was released today," the Tunisian foreign ministry said in a statement on Saturday, without giving numbers.
However, a Tunisian foreign ministry official, speaking anonymously, told AFP news agency that a total of 245 Tunisians detained had been freed.
They had been held since mid-May.
Tunis announced earlier this month that scores of its nationals were being held in western Libya by a militia belonging to the Misrata-based Libya Dawn alliance.
In Tripoli, Mohamed Abdelsalam al-Kuwiri, who heads a unit in the Tripoli-based government that combats illegal migration, told AFP that a final group of 90 Tunisians was released on Saturday, two days after 71 others were freed.
Kuwiri said they had been held for verification of their identity papers.
He said last week that his officers had helped secure the release of a first group, comprising dozens.
Meanwhile, Libyan doctors say fighting in the eastern city of Benghazi has killed eight people, including three children.
Khalil Gwaider, spokesman for the Benghazi medical centre, told the Reuters news agency the deaths overnight on Friday were the result of a random shelling that hit a park where children were playing as well as a school and other civilian areas, adding that five people were also seriously wounded.
Shelling in Benghazi happens almost nightly and civilian areas are often hit, leading to regular casualties.
Human Rights Watch has said that civilians, including foreign nationals, are trapped in several neighbourhoods of the city. It has urged fighters to let them depart safely.
Nearly four years after the ouster of longtime dictator Muammar Gaddafi, Libya is consumed by chaos and divided between two rival governments and parliaments.