Saying former City Councilman Dan Halloran knowingly perjured himself at trial, a federal judge threw the book at the disgraced politician on Wednesday — sentencing him to 10 years behind bars for masterminding a failed $200,000 bribery scheme to buy the 2013 Republican mayoral line for then-Democratic state Sen. Malcolm Smith.

“For five days, he lied on the stand,” White Plains federal Judge Kenneth Karas said of Halloran. “It was egregious.

“There was overwhelming evidence of his guilt,” added the judge as a stone-faced Halloran took a deep breath and nodded. “I saw him squirm and look uncomfortable on the stand … He lied and lied repeatedly. It was grotesque and offensive.”

The US Probation Department had recommended 6 ½ to 8 years of prison for Halloran, who tried to claim insanity as a defense at trial and is a “prince” in a pagan order that includes public floggings.

But Karas agreed with prosecutors that the Queens Republican deserved a harsher sentence because he “quarterbacked” the bribery scheme and lied under oath. The feds had asked Karas to hand Halloran a sentence of 12 ½ to 15 ½ years behind bars.

“When a public official takes cash like that, in a car, in an envelope, it’s so troubling, it’s shady,” said Karas, referring to how Halloran was caught red-handed taking bribes. “This causes us to be cynical about our leaders.”

Halloran, 42, was hoping to avoid jail by serving home confinement and embark on a new career as a scuba instructor.

“Mr. Halloran is worth so much more than the few bad choices that he made,” said the pol’s lawyer Jonathan Edelstein.

He also said that Halloran plans to appeal Karas’ sentencing, which includes two years of home confinement after Halloran leaves prison.

Halloran, who must surrender on April 17, declined comment afterwards — except to tell a photographer who nearly slipped chasing him, “Don’t hurt yourself!”

A White Plains federal jury last July deliberated a mere 85 minutes before finding Halloran guilty on five counts of bribery, wire fraud and racketeering.

The conviction ended a bizarre two-month trial in which Karas rejected Halloran’s bid to pursue an insanity defense related to a brain tumor he had removed in 2012 and also saw Halloran proceed with the case without Smith and another co-defendant, former Queens Republican Vice Chairman Vincent Tabone — even after a mistrial was declared. Both Smith and Tabone were convicted on federal corruption charges in February and have yet to be sentenced.

Halloran negotiated for $110,000 in bribes to be paid out to three city GOP leaders through the mayoral-race-fixing scheme, and he sought another $75,000 in payments for himself, the feds say. He was caught on tape telling an undercover FBI agent and a crooked Rockland County developer working with the feds that money “greases the wheels” in New York politics.

To get the GOP line, Smith — then one of the state’s top Democrats — would have needed the support of three of the five borough Republican committees. Queens and the Bronx were allegedly secured for the scheme, but Smith never secured a third borough committee.

The jury agreed with the feds that Halloran pocketed $20,500 in cash bribes for masterminding cross-party negotiations to help fix the Republican mayoral primary for Smith.

Halloran was also convicted for pocketing $18,300 in cash bribes and $6,500 in straw-donor campaign donations for agreeing to steer $80,000 of council discretionary funding for his district to a company he believed was controlled by those who paid him the bribes.

Halloran testified that he knew the undercover agent posing as a developer was asking him to break the law and that he only went along with the conversation in order to legally snag campaign cash. He claimed the money he secured through the Smith scheme was legitimate consulting fees and that he never planned to follow through with forwarding the council funds.

Following the jury’s verdict, Assistant US Attorney Douglas Bloom alleged that Halloran lied through his teeth about being innocent. Karas then also agreed, saying he “was also very troubled with Mr. Halloran in terms of his candor.”