A federal judge harshly criticized U.S. prosecutors’ treatment of a former spy agency official accused of leaking classified material, calling delays in the now-closed case “unconscionable” and comparing it to British tyranny in the colonial era.

In 2007, FBI agents raided the house of Thomas Drake, then an official at the National Security Agency, but it took another 2 1 / 2 years for officials to indict him, Judge Richard D. Bennett said at a sentencing hearing earlier this month in U.S. District Court in Baltimore, according to a transcript released Friday by the Secrecy News blog.

“And then, over a year later, on the eve of trial, in June of 2011, the government says, ‘Whoops, we dropped the whole case,’ ” Bennett said.

Drake was given a mild penalty for pleading guilty to the misdemeanor charge of exceeding authorized use of a computer: a year’s probation and 240 hours of community service. All 10 felony counts were dropped.

“That’s four years of hell that a citizen goes through,” Bennett said, according to the transcript. “It was not proper. It doesn’t pass the smell test.”

He went on: “I don’t think that deterrence should include an American citizen waiting two and a half years after their home is searched to find out if they’re going to be indicted or not. I find that unconscionable. Unconscionable. It is at the very root of what this country was founded on — against general warrants of the British.”

The prosecutor, William M. Welch III, who also headed the marred prosecution of Sen. Ted Stevens (R-Alaska) on corruption charges, had asked that Drake be fined $50,000 to serve as a deterrent and to “send a message” to other government employees who might contemplate leaking material to reporters.

Welch also complained that Drake had received a $10,000 prize for whistleblowing, a reference to the Ridenhour Prize given to Drake in April.

“At a minimum, the fine ought to be $10,000, but I would urge the court to impose the $50,000,” Welch said.

Bennett balked.

“There has been financial devastation wrought upon this defendant that far exceeds any fine that can be imposed by me. And I’m not going to add to that in any way,” said Bennett, who was nominated to the federal bench by President George W. Bush in 2003.

In contrast with his tough words for Welch, Bennett singled out for praise Drake’s public defenders, James Wyda and Deborah L. Boardman, saying their work on behalf of Drake was “at the highest level of professionalism.”

He said the matter was now closed and addressed Drake: “I wish you the best of luck in the rest of your life.”