A court in Tunis on Monday ordered the release of Ali Hamzi, a Tunisian suspected of involvement in the deadly attack on the US consulate in Libya last September, his lawyer Abdelbasset Ben Mbarek said.
The ruling came after Hamzi, 26, was interrogated by four FBI agents and a translator in Tunisia last month, in the absence of a defence lawyer, with Mbarek describing the methods used during the interrogation of his client as "scandalous."
"He has returned to his family," the lawyer told AFP.
"If he had been implicated in the attack, he would not have been released," he said, adding that his client remained under judicial control because he was still charged with belonging to a terrorist group.
Hamzi was detained while trying to enter Turkey after the September 11 attack on the US mission in Libya's eastern city of Benghazi, in which the ambassador Chris Stevens and three other Americans were killed.
He was deported back to Tunisia in October, where he was charged with belonging to "a terrorist group based abroad."
He had refused to be interrogated by FBI agents.
Tunisia's justice ministry has defended its right to cooperate fully with the United States in combatting terrorism.