WASHINGTON- A federal court Tuesday threw out the terrorism conviction of Osama bin Laden's former bodyguard and driver, ruling that he was improperly prosecuted before a military tribunal for a war crime that did not exist at the time he was accused of having committed it.

The unanimous decision by a three-judge appellate panel came in the case of Salim Ahmed Hamdan, who authorities say met bin Laden in 1996 at an Al-Qaida training camp.

Hamdan was tried in 2008 before a military commission at the U.S. prison at Guantanamo Bay, Cuba. He was acquitted of conspiracy but convicted of material support of terrorism; he was sentenced to 51/2 years in prison and released in 2009 to his family in Yemen.

In seeking to overturn his conviction, Hamdan argued that material support of terrorism was not considered a war crime under international law when he was accused of aiding Al-Qaida. In a 28-page ruling, Judge Brett Kavanaugh of the U.S. Court of Appeals for the D.C. Circuit agreed.

"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 ... it should have done so," wrote Kavanaugh.

Joseph McMillan, an attorney for Hamdan, praised the decision, saying, "We are gratified that even in the midst of the perceived national emergency the American courts are prepared to uphold the rule of law in that way and insist that we proceed with accordance of law."

McMillan said Hamdan had not learned of the ruling as of Tuesday afternoon.

Dean Boyd, a Justice Department spokesman, said the government was reviewing the decision and declined to comment further.

Hamdan was charged under the 2006 Military Commissions Act, a law that authorized the government to try detainees before military tribunals for war crimes.

It is not clear how the ruling will affect other cases before military commissions. There are 166 detainees at Guantanamo. The Pentagon has cleared 87 for release or transfer abroad, and the rest could stand trial.

Among those facing charges before a military commission is Khalid Sheikh Mohammed, the alleged mastermind of the Sept. 11, 2001, terrorist attacks.