He’ll be saying his prayers behind bars.

A crooked rabbi was sentenced to four years in the slammer today for trying to shake down a hedge fund for $4 million by promising to cover up concocted claims of insider trading.

In an unusual move, the judge also ordered Rabbi Milton Balkany locked up immediately, saying she was “seriously concerned” he might try to run away if he remained free on bail.

Balkany — who made an impassioned plea for no jail time — stood stock still as his punishment was imposed, then smiled and blew kisses to about a dozen family members as he was led off by deputy U.S. marshals.

“Have a good shabbos,” Balkany said.

Manhattan federal Judge Denise Cote told the 64-year-old Brooklyn resident that he had committed “very serious crimes” by trying to blackmail billionaire Steve Cohen’s SAC Capital Advisors.

“The lack of contrition, remorse and acceptance of responsibility, in my mind, is profound,” she said.

But Cote cut Balkany a break from sentencing guidelines that recommended at least seven-plus years behind bars, citing his “lifetime of good works” and the “generosity of spirit” attested to in 87 letters of support.

Although his lawyer said Balkany would remain silent due to a planned appeal, he launched into an impromptu, 20-minute speech when given the chance.

While he didn’t address his extortion conviction, Balkany denied charges that he misused a $700,000 Housing and Urban Development grant, for which he struck a deferred prosecution deal in 2004.

He also vehemently denied uncharged allegations that he schemed to bribe federal officials for favorable treatment of Jewish inmates, saying a $240,000 payment went “to a consultant, and we can prove it to the penny.”

“I never gave a toothpick to a public official in my life,” said Balkany, who at several points got so excited that he had to adjust his yarmulke to keep it from falling off.

A spokesman for SAC Capital declined to comment.