WASHINGTON— A federal appeals court on Tuesday threw out the conviction of Salim Ahmed Hamdan, a former driver for Osama bin Laden who served a prison term for material support for terrorism.

In a 3-0 ruling, the appeals court said that material support for terrorism was not an international-law war crime at the time Hamdan engaged in the activity for which he was convicted.

Hamdan was sentenced to 5 1/2 years, given credit for time served and is back home in Yemen, reportedly working as a taxi driver.

“If the government wanted to charge Hamdan with aiding and abetting terrorism or some other war crime that was sufficiently rooted in the international law of war at the time of Hamdan’s conduct, it should have done so,” wrote Judge Brett Kavanaugh of the U.S. Circuit Court of Appeals for the District of Columbia. He was joined by two other judges, all appointed by Republican presidents.

Hamdan met bin Laden in Afghanistanin 1996 and began working on his farm before winning a promotion as his driver.

Defense lawyers say he only kept the job for the $200-a-month salary. But prosecutors alleged he was a personal driver and bodyguard of the al-Qaida leader. They say he transported weapons for the Taliban and helped bin Laden escape U.S. retribution following the September 11, 2001 attacks.

Hamdan was captured at a roadblock in Afghanistan in November 2001. In a trial at Guantanamo Bay Military Base, a six-member military jury in 2008 cleared Hamdan of two charges of conspiracy while finding him guilty of material support for terrorism.