A federal judge in Montana overturned an Internal Revenue Service rule that would allow many political non-profit groups to keep their donor lists private.

The ruling upends a change the IRS made last year that permitted so-called Section 501(c)4 groups, known as “social-welfare” organizations, to keep their donor lists private. A federal judge said the IRS didn’t follow proper procedure in writing the rule and needs to allow the public to weigh in on the change before altering the tax code.

“Then, and only then, may the IRS act on a fully informed basis when making potentially significant changes to federal tax law,” U.S. federal Judge Brian Morris said in the opinion published Tuesday evening.

Montana Governor Steve Bullock, who is also a Democratic presidential candidate, sued the IRS, saying that the change limited information states received about political donors. The IRS rule only required the groups to disclose their donors if an auditor requested to see it.

The ruling is a blow to Treasury Secretary Steven Mnuchin who touted the rule, saying it protected donor privacy because the IRS didn’t need the information to enforce tax laws. Democrats had criticized the agency’s move, saying it opened up the possibility for foreign interests to influence elections.

Among the organizations with 501(c)4 status are the National Rifle Association, the Democratic Socialists of America, the AARP and Americans for Prosperity, the conservative group backed by the billionaire brothers Charles and David Koch.

The groups can be engaged in politics, so long as they don’t spend more than half of their money on campaign advertisements or activities to sway an election. Donors do not have to be disclosed to the public.

The case is Bullock v. Internal Revenue Service (4:18-cv-00103).

This article was provided by Bloomberg News.