Tunisia said Tuesday it will soon extradite Al-Baghdadi Al-Mahmoudi back to his homeland, after detaining the former Libyan prime minister for eight months.

Al-Mahmoudi was arrested in September for illegally crossing the frontier into Tunisia as he tried to flee to Algeria, where members of former Libyan leader Moammar Gadhafi's family had sought refuge.

Lawyers and human rights groups had opposed the extradition, saying Al-Mahmoudi might be harmed by Libya's new ruling authorities — representative of the rebels who overthrew Gadhafi last year.

"Tunisia will never be a refuge for those who represent a threat to Libya's security," said Tunisian Prime Minister Hamadi Jebali on Tuesday, following a visit by his Libyan counterpart, Abdurrahim el-Keib.

Mondher Bedhiafi, a spokesman for Tunisia's justice ministry, said the extradition would occur in the coming weeks, but only once necessary procedures were completed.

He said according to Tunisia's penal code, once the extradition request had been approved by a panel of judges the final decision was up to the prime minister.

Libyan authorities have assured Tunisia that Al-Mahmoudi will receive a fair trial, added Bedhiafi.

Al-Mahmoudi's lawyer denounced the decision as "unjust and against Tunisian law."

"The Tunisian authorities show that they do not respect human rights and have done away with humanitarian principles," said Bechir Essid, noting that there was no guarantee for Al-Mahmoudi's safety given the current state of insecurity in Libya.

Libya has been clamoring for the repatriation of Al-Mahmoudi to answer for crimes it says he committed as the final prime minister under Gadhafi.

Officials from the former regime have not fared well in the hands of the rebels, with Gadhafi and one of his sons executed on capture last year.

In January, 15 Tunisian and international human rights groups - including Amnesty International and Human Rights Watch - signed a statement opposing Al-Mahmoudi's extradition, saying he risked death or torture if he was returned to Libya.