A solemn and weary Harry Thomas Jr. stood before a federal judge Thursday and blamed “a sense of entitlement” for his having used his former position as a D.C. Council member to steal hundreds of thousands of dollars intended for youth programs.

U.S. District Judge John D. Bates then imposed a sentence of three years and two months in prison, the most severe criminal sanction ever given a local elected official in the District.

“Somehow . . . I lost my moral compass,” Thomas told Bates, explaining his actions for the first time. “I went astray and lost my way.”

Bates gave Thomas some credit for a record of community service to young people but told him that he had “plainly and significantly abused” his position of public trust.

“You stole from the people who elected you, and you stole from the youth who could have benefited from those funds,” the judge said.

Thursday’s sentencing marked the end of an 18-month saga that started with questions from a political opponent and grew into the most serious graft allegations ever leveled against an elected District official. The lengthy sentence also represents a major victory for federal prosecutors, who remain engaged in investigations of other city officials, including Mayor Vincent C. Gray (D) and council Chairman Kwame R. Brown (D).

The 38-month sentence was less than the 46 months that U.S. Attorney Ronald C. Machen Jr. had requested, but it was significantly more than the 18 months that Thomas’s attorneys had argued for.

“A case like today’s, a sentence like today’s, does send a powerful message that you’re going to be held accountable,” Machen said in an interview. “That should send a message to others that we’re not going to tolerate a culture of self-dealing or self-enrichment in the District.”

Two men who aided Thomas also have pleaded guilty to felonies. Machen said his office continues to probe the theft, but he declined to offer details.

Thomas, 51, pleaded guilty in January to a pair of felonies — theft of funds concerning federal programs and filing a false tax return — a day after resigning the Ward 5 council seat that he held for five years and that his father had held for 12 years.

In their sordidness, the crimes approached the realm of cartoon villainy. Thomas steered taxpayer money intended for children through various nonprofit groups into his own pocket, prosecutors said, using the funds for expensive trips, a $69,000 luxury sport-utility vehicle and pairs of “exotic shoes,” among other items.

Thomas and his attorneys went to great lengths to detail a long record of community service that predated his service on the council. Ninety-two letters of support were included in a filing to the judge, and attorneys called three witnesses Thursday to help make the case for leniency.

One of Thomas’s nephews, Stephen Kyle Truhart, and Paris Inman, a Little League organizer in the District, testified that Thomas was a diligent coach and father who spent thousands of hours mentoring and coaching city youths.

“If you go to a game and see a kid, especially a black kid from the District, he probably played for Harry or I,” Inman said. “I didn’t know council member Harry Thomas well. I knew Coach Harry Thomas.”

In one of the hearing’s most dramatic moments, Thomas’s mother, 82-year-old former elementary school principal Romaine B. Thomas, stood before Bates and pleaded for mercy.

“I have lectured him on the harm and shame he has brought” to his family, she said. “My son has suffered severely in these past few months through disappointment in himself, demoralization, despair and dejection.”

Harry Thomas picked up on those themes in his comments, noting the “humiliation” that he had brought to his family, colleagues and city. He called his prosecution “my weakest and lowest moment in life.”

Family members, including Thomas’s wife, Diane Romo Thomas, filled a front-row bench in Bates’s courtroom. Several wept as Harry and Romaine Thomas spoke. Scores of other supporters were among the more than 100 in attendance.

They listened as Assistant U.S. Attorney Jonathan W. Haray decried Thomas’s “hypocrisy” for “touting his devotion to kids at the very same time he was stealing money earmarked for children’s programs.” He also called the Thomas case a “historic” instance of corruption in the District government, “an all-time low to the people of this city.”

“This court has a rare and clear opportunity to send a loud and clear message to elected officials,” Haray said. “The message is simple: If you steal from the people you serve, you will pay a high price.”

As part of his sentence, Thomas will remain on probation for three years after leaving prison and will have to pay the District restitution for his theft. But the amount of restitution remains to be determined. Thomas’s attorneys argued Thursday that he should be liable only for the $353,500 said to have gone to him personally. But Bates suggested that Thomas might also be on the hook for nearly $100,000 more, for city funds that he redirected from anti-drug and youth-intervention programs to a 2009 inaugural ball that he helped organize.

Bates reserved judgment on the matter and asked attorneys to file arguments in the coming weeks. He declined to levy a fine against Thomas in addition to restitution. The judge said he found that Thomas did not have the ability to pay a fine, citing a confidential pre-sentencing report that includes details of Thomas’s finances.

Thomas did not speak to reporters after the hearing, and neither did his attorneys or family members.

D.C. Attorney General Irvin B. Nathan, who brought Thomas’s theft to the attention of federal prosecutors last summer, called the sentence “a just resolution of this sad matter.”

The sentence, Nathan said, “sends a strong message to those who would abuse the power of their District government positions to enrich themselves at the expense of the public: There will be serious consequences for such unlawful actions.”

Mayor Vincent C. Gray (D), a onetime Thomas ally, issued a statement saying that “justice has been done and Mr. Thomas will be held accountable for his actions.”

“This case is an important reminder that public officials must never forget for whom we work and that all public servants must be guardians of the public trust,” Gray said. Gray and his campaign workers remain under investigation because of questions about campaign financing.

Prosecutors agreed to let Thomas surrender to the federal Bureau of Prisons at an unspecified date.

Although it is federal policy to place inmates in facilities within 500 miles of home, Thomas’s attorneys asked Bates to recommend that Thomas be sent to one of two more- distant federal prison camps — in Pensacola, Fla., and Montgomery, Ala. — that are regarded as among the most desirable locations in the federal system. Bates did not say whether he would grant that request.