A Tunisian court of appeal has freed Muammar Gaddafi's former Prime Minister Al-Baghdadi Ali al-Mahmoudi, who was sentenced to six months in jail last week after he was arrested near the North African country's border with Algeria.

The judge has decided to free Mahmoudi and two of his aides, his lawyer, Mabrouk Korchid told Reuters.

In the highest profile detention of a Gaddafi associate to date, the court jailed Mahmoudi for illegally entering the country.