Prosecutors were seeking a sentence of at least 30 years for Hamdan, who had faced life in prison, in the first war crimes trial since World War II.
The judge, Navy Capt. Keith Allred, earlier ruled that Hamdan would receive five years of credit for the time he has served at Guantanamo Bay since the Pentagon decided to charge him.
"I would like to apologize one more time to all the members and I would like to thank you for what you have done for me," Hamdan told the panel of six U.S. military officers, according to the Associated Press.
Under tribunal rules, the jury imposes the sentence, not the judge. A Pentagon legal official later reviews the sentence and can reduce but not increase it.
"I hope the day comes that you return to your wife and daughters and your country, and you're able to be a provider, a father, and a husband in the best sense of all those terms," the judge told Hamdan.
Hamdan responded: "God willing," according to media reports.
Hamdan, a Yemeni, was convicted by the six Pentagon-appointed military officers of aiding terrorism by chauffeuring bin Laden around Afghanistan at the time of the Sept. 11, 2001, attacks. Hamdan was acquitted of more serious conspiracy charges.
Earlier Thursday, Hamdan pleaded with the military jury to spare him a sentence of life in prison.
It remains unclear what will happen to Hamdan once his sentence is served, since the U.S. military has said it won't release anyone who still represents a threat. Capt. Allred said he did not know what would happen to Hamdan once his sentence is complete, but said he would likely be eligible for the same administrative review process as other prisoners.
Hamdan was captured in Afghanistan in 2001. He was taken to the U.S. detainee camp at Guantanamo Bay in May 2002 and named as one of the first prisoners to face prosecution. His case has been the subject of repeated court battles, including a Supreme Court ruling that struck down an earlier version of the tribunal system.
Hamdan said Thursday he merely had a "relationship of respect" with bin Laden, as would any other employee.
"It's true there are work opportunities in Yemen, but not at the level I needed after I got married and not to the level of ambitions that I had in my future," he said, reading in Arabic from a prepared statement.
Hamdan also said he was stunned to learn his boss was behind the USS Cole bombing on Oct. 12, 2000, at the Yemeni port of Aden that killed 17 U.S. sailors. Hamdan said he initially believed Yemeni news reports that Israel was behind the bombing.
"It was a big shock for me," Hamdan said. "The way I look to bin Laden changed a lot."
But Hamdan said he went back to work for him because he could not find another job that paid enough to support his family.
"I couldn't beg," he said. "I had to work. ... I was thinking to myself, God willing, this would not occur a second time."