A German court ordered Friday that a man who allegedly worked as a bodyguard for Osama bin Laden must be returned after his deportation to Tunisia, saying the expulsion was illegal as he risks torture there.

"This afternoon's court decision shows the deportation to be grossly illegal and infringing on basic principles of the rule of law," the administrative tribunal in Gelsenkirchen said in a statement, adding that it "must be reversed".

Judges said authorities had failed to reveal to them the time of the flight, meaning a ruling blocking the expulsion only arrived when the plane for Tunis was already airborne.

Even then, the court added that authorities "knowingly" defied the order by completing the transfer to Tunisian security forces, who immediately placed the deportee under arrest.

The 42-year-old, identified by German authorities only as Sami A. and by Tunis as Sami Idoudi, had lived in Germany for more than two decades, but outrage over his presence grew in recent months as Germany cracks down on failed asylum seekers.

He had previously successfully argued against his deportation, saying he risked being tortured in his homeland.

The Gelsenkirchen court ruled against the deportation late Thursday, upholding the assessment that the suspect potentially faced "torture and inhumane treatment".