Federal Judge Mark Wolf imposed that sentence Wednesday, essentially saying he wanted to send a message that cooperation against political corruption will be rewarded.

This was Lally, outside the courthouse after it was all over: “I can’t wait to move on. I think I did the right thing. I think Judge Wolf treated me very well. Thank you…”

But before it began and inside the courthouse, Lally asked me: “How much time do you think I’m going to get?”

That was the last remaining question to the drama that is sending the convicted former speaker and lobbyist Richard McDonough to prison in time to have turkey dinner next month. Having played an instrumental role in convicting them, Lally was here to get both his punishment and his reward.

The letters asking the judge for clemency for Lally call him “an average Joe,” but the 50-year-old, high-rolling, high-fiving fireplug was never called that by either the defense or the prosecution.

The one thing both sides agreed on was that Lally was a braggart, name dropper, tax cheat, compulsive gambler, thief, inveterate liar and check forger-er, as well. Add to that Wolf’s characterization Wednesday, delivered to Lally, that “you were a thoroughly unsavory and dishonest businessman.”

Mind you, this was the guy from whom the state of Massachusetts bought $17.5 million of software after he paid almost $1 million in kickbacks to DiMasi, lobbyist McDonough and accountant Richard Vitale. For his part, Lally made $4 million.

Said the judge to the not-so-average Joe, “When Mr. DiMasi and Mr. McDonough decided to sell the power of their offices, they decided to approach you because they knew you were dishonest.” In that they were good judges of character, Wolf added.

But Lally had his good points. “You testified fully and truthfully,” the judge concluded.

Through Lally, the government was able to connect the dots on the conspirators’ scheme with Lally’s emails and phone calls and his cool testimony at trial.

The government had acquired Lally as a witness just before the trial began when the salesman who was about to go to trial with his co-defendants cut a deal. This deal was to tell the truth. In return the government recommended a sentence of two to three years.

Judge Wolf did it six months better. “I would have sentenced you to seven years in prison” — the same McDonough got — “if you had gone to trial and been convicted,” Wolf told Lally. In addition, the judge said, “You’re $1 million better off,” because the government had allowed Lally to keep his house, which was sold to pay off the IRS, the DOR and his mother-in-law.

“I’m deeply sorry for what I have done,” said Lally, standing upright before the judge, and wiping tears from his eyes. “I realize now how greedy and self-centered I have been. … I don’t want to be away from my family. But I know I must be punished.”

Eighteen months, announced the judge, beginning in December, and considerably less than the eight years DiMasi got.

“This case shows it’s hard to convict corrupt politicians in Massachusetts,” Wolf said. “Unless someone like you comes forward and cooperates, it’s hard to prosecute one of these cases. I want to send a message your cooperation has been rewarded.”

But the judge also told Lally he needs some work on anger management. That after the judge got a letter informing him that the basketball coach who dropped Lally’s sixth-grade daughter from the team filed for a restraining order, claiming that Lally had threatened him.

Lally’s left with handshakes from the government prosecutors, a great deal and a chance to become an average Joe.