The drunken guest who accidentally fired a pistol at a million-dollar Waldorf-Astoria wedding reception took a plea deal Wednesday ​that allowed him to avoid jail time.

Vladimir Gotlibovsky, 45, copped to one count of criminal possession of a firearm and was sentenced to a conditional discharge for the embarrassing incident on June 13, 2015.

​​

As part of the agreement, Vladimir must stay out of trouble for three years.

The lavish ceremony was canceled after his legal 9mm Ruger discharged in his right pocket, grazing a woman’s head at a boozy pre-wedding cocktail hour.

The bullet ricocheted off the floor and injured three others struck by flying marble, glass and tile, officials said.

In the ensuing chaos, Vladimir slipped the gun to his brother, Felix Gotlibovsky, 52, in the hotel bathroom. Felix then passed it to their mother who handed it off to Vladimir’s wife.

The brothers, both of Brighton Beach, were originally hit with felony weapons possession and tampering with evidence charges.

Assistant District Attorney Joshua Steinglass moved to dismiss the case against Felix Wednesday in Manhattan Supreme Court, a request granted by Justice Maxwell Wiley.

“His actions can best be viewed as an impulsive action taken to protect his brother from the consequences of his brother’s conduct,” the prosecutor said.

It was the second time Vladimir, who owns a liquor store, was involved in a firearm discharge in one year, Steinglass previously told the judge.

He described him in court filings as “a walking menace to public safety.”

The prosecutor said that Vladimir is barred from ever owning a gun again.

Bride Anna Goldshmidt is suing the Waldorf-Astoria for canceling the opulent nuptials because of the shooting, dashing her fairytale wedding to Elan Stratiyevsky.