By Kim Ghattas
BBC News, US base in Guantanamo
Mr Hamdan's trial was the first of Guantanamo's tribunals
It was a dramatic and emotional day in the military court in Guantanamo Bay, but a strange one as well, with both the defence and the prosecution saying they felt vindicated.
It was a sign perhaps of how confused the process actually is, with even the judge saying he did not know what would happen to Salim Hamdan, Ossama bin Laden's driver, after the remaining five months of his sentence have been served.
The jury, after having found Mr Hamdan not guilty of the more serious charges of conspiracy to commit murder but guilty of material support for terrorism, deliberated for about an hour and a half on Thursday.
In the end, it returned with a sentence of only 66 months, including the time already served of 61 months - a clear signal they saw Mr Hamdan as indeed just a driver who had been hanging out with the wrong crowd.
But the sentence was far more lenient than anyone expected.
Even civil and human rights observers said they were positively shocked.
Tears of joy
Mr Hamdan, wearing a traditional Yemeni white robe, a dark jacket and white head dress, was visibly nervous when the six military jurors first walked in.
He stood silently, slightly fidgety, awaiting to know his fate.
He remained impassive at first, in a state of disbelief, perhaps doing the maths in his head to determine what this meant about how long he would remain a convict.
He then said a few words in Arabic, apologising for any harm he may have caused and thanked the judge, the jurors and his defence team.
The lead defence laywer, retired navy officer Charlie Swift, was standing next to Mr Hamdan and raised his arms in a cheer when the sentence was announced.
He appeared on the verge of tears as he hugged his client, relieved after five years of working on a case that seemed doomed to fail.
But Mr Hamdan will not necessarily be a free man in January.
"After (you have served your sentence), I don't know what happens," the judge, Capt Keith Allred, told Mr Hamdan.
"I hope the day comes when you return to your wife and your daughters and your country."
Mr Hamdan, replied with "Inshallah" (God willing) and got an "Inshallah" back from the judge.
"He'll still be retained as an enemy combatant (after he serves his sentence)" said Pentagon spokesman Bryan Whitman back in Washington.
"But as an enemy combatant, he then becomes at that time eligible for the annual review board process to determine whether he's eligible for release or transfer."
This continued detention was expected and this is part of why the defence lawyers called the process a "farce" and the human-rights groups say the trials in Guantanamo are fundamentally unfair, despite the Hamdan sentence outcome.
They have also criticised the secrecy surrounding some of the hearings and evidence heard.
The military commissions set up by the Bush administration also allow as evidence hearsay and coerced confessions.
After the sentence hearing was over, the defence team walked the short distance from the courthouse on top of a hill, down to the massive hangar where journalists covering the trial are based.
They appeared literally ecstatic, saying this was a damming indictment of the process and a clear sign that the government had over reached and over-reacted to Mr Hamdan's case.
They also praised the US military - the jury was made of six anonymous military jurors, representing the air force, the army and the navy.
The defence team included two uniformed and one retired officer.
"This sends a long shot across the bow to the political ideologues who hoped that the military would serve as their pawns," said the civilian defence laywer Joseph McMillan, adding it was a testament to the integrity of the military.
Retired Lt Cmdr Swift also said this was "a vindication of the military, not of the military commissions".
Lt Cmdr Brian Mizer, a member of the defence team, said the men had been given a fair trial.
He said he had no doubts about what he was doing and had not been criticised by any colleagues, at least not openly.
And although the sentence was much less than the 30 years sought by the government, the prosecution put a positive spin on the outcome.
"If anything it's a vindication of the system it proves that this system is very fair and impartial and capable of prosecuting war criminals," said John Murphy, one of the prosecutors and an attorney with the US department of justice.
But law experts and civil rights group said this was a slap in the face of the administration and its detention policies.
"They chose to make this a test case (for future cases to be tried in Guantanamo). But they never imagined that it would result in such a stunning rebuff," Washington-based lawyer David Remes told the Associated Press news agency.
Mr Remes represent 15 inmates in Guantanamo.
The verdict and the sentence will have no impact and set no precedent for future cases to be tried at the US naval base in Guantanamo.
Mr Hamdan's sentence now goes for mandatory review to a Pentagon official who can shorten it but not extend it.
As he left the courtroom, Mr Hamdan turned around one last time, smiled and said "bye bye" before going to call his wife in Yemen.