HOUSTON, May 27 (Reuters) - A U.S. judge on Wednesday handed down 65-year prison sentences to two founders of a U.S. Islamic charity convicted of illegally funneling $12.4 million to the Palestinian militant group Hamas.

The sentences came some six months after a grand jury convicted the Holy Land Foundation and five of its leaders for conspiracy to support a foreign terrorist organization, money laundering, tax fraud and other charges.

The foundation, based in a Dallas suburb, was one of the biggest Islamic charities in the United States before the government shut it down in the wake of the Sept. 11, 2001 attacks.

The group said it focused on legitimate disaster relief and aid to Palestinian refugees.

"I did it because I cared, not at the behest of Hamas," Shukri Abu Baker, 50, told a federal court in Dallas as U.S. District Judge Jorge Solis sentenced him and Ghassan Elashi, 55, to 65 years in prison, the Dallas Morning News reported.

Three other defendants were sentenced to lesser terms ranging from 15 to 20 years.

"You didn't tell the whole story. Palestinians were in a desperate situation, but that doesn't justify supporting Hamas," the judge said, according to the newspaper.

The sentencing, which followed a 2007 mistrial and a retrial that ended last year, is seen by some as a milestone in the U.S. government's crackdown on financing of overseas terror groups.

"These sentences should serve as a strong warning to anyone who knowingly provides financial support to terrorists under the guise of humanitarian relief," David Kris, Assistant Attorney General for National Security, said in a statement.

Prosecutors said the Holy Land Foundation funneled money to Hamas, which seized control of the Gaza Strip in 2007 and is pushing for an independent Palestinian state. The U.S. government declared Hamas a terrorist organization in 1995.

The Islamic community has said the case highlights what it sees as the unfair scrutiny that U.S. Muslims have been subjected to since the 2001 attacks and that it criminalizes legitimate charitable activities central to Islam. (Editing by Paul Simao)