ALBANY — A federal judge has struck down a sweeping state law that required nonprofits engaging in lobbying to disclose far more information about their donors than previously called for. The measure had been pushed by Gov. Andrew M. Cuomo's administration.

The law — passed at 3 a.m. on the final night of the 2016 legislative session — was widely viewed as having been targeted towards government reform groups that have been critical of Cuomo.

Federal Judge Denise Cote, ruling Monday in the Southern District of New York, wrote that the state law was overly broad and infringed on free speech rights.

"The First Amendment rights to publicly discuss and advocate on issues of public interest, and to do so anonymously, have long been recognized," Cote wrote. The state law "sweeps far more broadly than any disclosure law that has survived judicial scrutiny."

Attorney Randy Mastro represented the government reform group Citizens Union in the suit seeking to overturn the law. While Citizens Union has advocated for more transparency from elected officials, the group argued in this case that the donor disclosure law would chill the free speech rights of government critics and create major administrative burdens.

"This state law targeted not-for-profit 'good government' groups that have had the temerity to raise ethics issues and try to get the government to do better," Mastro said in a statement. "It's blatantly unconstitutional, and we are therefore grateful to the court for invalidating it. The rule of law may be under siege in Washington these days, but today, it's alive and well in New York."

During the 2016 legislative session, Cuomo introduced a reform bill whose stated intention was to address political corruption in the wake of the 2010 Citizens United ruling by the U.S. Supreme Court, which allowed unlimited electoral spending by outside interest groups.

After Citizens Union and other New York reform groups critiqued Cuomo for not going far enough, especially in the wake of several major Albany corruption cases, a Cuomo spokesman called the groups "shadow lobbyists."

In January 2016, the Times Union published an article discussing how good government groups in New York sometimes do not disclose their donors, and how the donors that were publicly known have had connections to interest groups — such as the state teachers union or an anti-tort reform group —whose agendas some reform groups had pushed. The Cuomo administration cited the article in justifying their criticism of the organizations.

In the early morning of the legislative session's final day in June 2016, the ethics bill passed the Legislature. While the provisions combatting outside electoral spending had been widely known, the provisions targeting lobbying donors had barely been discussed before they were voted upon by the state Senate and Assembly.

In a statement, Cuomo spokesman Rich Azzopardi said the administration was considering an appeal of the federal judge's ruling.

"Everyone preaches transparency until transparency shows up on their own front door," Azzopardi said. "We are reviewing this decision and considering next steps, including appeal. But the question remains: What is the advocacy industrial complex hiding?"

Charitable organizations — designated by the IRS as "501(c)(3)s" — can take tax-deductible donations, but can only engage in limited amounts of lobbying under IRS rules. Issue-oriented nonprofits — designated as "501(c)(4)s" — can engage much more widely in advocacy.

Under state law, the charitable groups do not have to disclose their donors for Albany lobbying efforts, while issue-oriented nonprofits that hit certain spending thresholds must disclose them. But it's also not uncommon for the finances of the two types of nonprofits to overlap for a single organization — a situation the Cuomo-backed law had sought to address.

The law would have required 501(c)(3) charities to disclose all their donors of more than $2,500 over six months if they contributed more than $2,500 to substantial lobbying campaigns run out of issue-oriented nonprofits.

Critics of the law also were concerned about a provision mandating that 501(c)(4) nonprofit groups that spend more than $10,000 a year on any public policy communications report the name and address of donors who give $1,000 or more.

The New York Civil Liberties Union also filed litigation seeking to strike down the law, and was listed among the winning plaintiffs in Monday's federal ruling.