A Manhattan judge Monday dismissed a bribery case against former Brooklyn state assemblyman Alec Brook-Krasny who was accused of helping a crooked doctor run a $6.3 million pill mill.

In July, the ex-pol was acquitted at trial of conspiracy and fraud charges, but the Manhattan Supreme Court jury hung on four misdemeanor counts of commercial bribery.

Defense lawyer James McGovern argued in a dismissal motion that the city’s Special Narcotics Prosecutor didn’t have jurisdiction to try a case that no longer had drug-related charges. Justice Ann Scherzer agreed and granted the motion.

“We are absolutely thrilled that this unjust prosecution has finally come to an end with a full dismissal of all of the charges against Mr. Brook-Krasny,” said McGovern of the firm Hogan-Lovells.

After Brook-Krasny resigned from public office in 2015, he became chief financial officer of Quality Laboratory Services in Sheepshead Bay.

Prosecutors had said that doctor Lazar Feygin directed his urinalysis tests to Brook-Krasny’s clinic, and the two allegedly conspired to delete positive alcohol results from patients’ reports.

This allowed Feygin to continue prescribing oxycodone to heavy drinkers — despite the dangers of the combination.

In March, Feygin pleaded guilty to 16 felonies in exchange for five years in prison.