CONCORD — A federal judge has thrown out a 20-year prison sentence for a heroin dealer sentenced during a tough-on-drugs crackdown by former U.S. Attorney General Jeff Sessions.

Manchester resident Alfredo Gonzalez had the misfortune of being sentenced during a 1 1/2-year period when Sessions, former President Trump’s first attorney general, overrode the policies of his predecessor and demanded stiff sentences in drug trafficking cases, according to a ruling issued by U.S. District Court Judge Paul Barbadoro.

In a 10-page ruling, Barbadoro pointed out that Gonzalez received one of the stiffest sentences of 16 co-defendants arrested in a single 2017 case involving heroin trafficking in Manchester.

Congress later softened Sessions’ crackdown with the First Step Act of 2018, which Trump signed into law in December 2018. Trump signed the criminal justice reform legislation six months after Gonzalez received his mandatory minimum sentence.

“He faced a disproportionately harsh sentence when compared to similar defendants who were convicted before or sentenced after this brief 18-month window,” Barbadoro wrote in an order issued on Tuesday.

The order calls for a new sentencing hearing. Barbadoro, an appointee of George H.W. Bush, said Gonzalez committed a serious crime and deserves a substantial sentence, but not 20 years.

Federal prosecutors in New Hampshire had said that the original sentence should stand, noting Congress did not extend the reach of the First Step law to previous convictions.

Gonzalez had earlier appealed his jury conviction and been turned down. And Barbadoro rejected his request for compassionate release over fears of COVID-19 infection. In court filings, Gonzalez has said he would live with a sister in Manchester if released and work for an asbestos abatement contractor.

According to court filings, Gonzalez was involved in three transactions that, together, totaled more than 1 kilogram of heroin, an amount that triggered enhanced sentencing. An earlier conviction for cocaine trafficking was another factor.

All defendants in the case received sentences lower than Gonzalez. Many were more than 12 years lower.

Barbardoro has not set a date for a new sentencing hearing.