A feisty former probation judge took a plea deal Monday for drunkenly slugging a Legal Aid lawyer who shoved him outside a party.

Judge Robert Beltrani, 54, copped to attempted assault and agreed to complete an anger management program and community service.

“I hit him,” Beltrani admitted in Manhattan Criminal Court of the Oct. 20, 2016, altercation with attorney Sam Roberts, 48.

If he stays straight for six months, the charge will be reduced to a violation, which is not a crime.

Beltrani’s defense lawyer still insists his client is innocent. “If you push someone, being punched in return is not an unreasonable expectation,” said attorney Terry Saunders. “This was a fight. The fact that one of the fighters sustained injury does not make it an assault.”

Beltrani was axed in early November after a disciplinary hearing determined his unseemly behavior didn’t befit a Board of Parole administrative law judge.

The former Republican state Senate candidate previously argued that he had acted in self-defense outside the holiday party at 115 W. 18th St.

In surveillance video obtained by The Post, Roberts strolls over to Beltrani, and after a heated one-minute exchange, pushes him with his left hand. The judge responds with a right cross to the face, knocking Roberts to the ground.

“It was not a fight I wanted,” Beltrani previously said. “It was after he hit me that I hit him.”

The men, who had each tossed back at least four drinks, were introduced for the first time earlier that evening. Beltrani said that Roberts had almost immediately insulted him.

Roberts replied, according to Beltrani, ’“You want to help people, help yourself, you’re a parole judge.’”

The attorney, who suffered a black eye and separated shoulder, said he was satisfied with the deal. “I think it was a very fair plea arrangement and hope Mr. Beltrani gets the help he needs,” Roberts said.