The ruling is a win for President Donald Trump, who is resisting efforts to turn over his tax returns in a battle largely playing out in the courts.
US District Judge Morrison C. England Jr. of the Eastern District of California on Tuesday wrote "while this Court understands and empathizes with the motivations that prompted California" to pass the law, "the Act's provisions likely violate the Constitution and the laws of the United States." England noted that it is not the court's role "to decide whether a tax return disclosure requirement is good policy or makes political sense."
The judge said the law would set a dangerous precedent and become a slippery slope for other kinds of disclosures. He also said it presents a "troubling minefield " that would permit a state to make its own demands.
Last month -- ruling from the bench -- the judge had signaled he was inclined to rule in favor of the President.
The opinion is likely to be appealed to the 9th US Circuit Court of Appeals by the California secretary of state and state Attorney General Xavier Becerra. England is a George W. Bush appointee.
Lawyers for Trump had argued in court papers that the law adds an "unconstitutional qualification" to the fixed set of qualifications for the presidency set forward in the Constitution and violates the First Amendment.
California Democratic Gov. Gavin Newsom signed the state's Presidential Tax Transparency and Accountability Act last July.
"The United States Constitution grants states the authority to determine how their electors are chosen, and California is well within its constitutional right to include this requirement," he said in a statement at the time.
A similar lawsuit was filed Tuesday by Republican voters along with the Republican National Committee and the Republican Party of California, who argue that this a political maneuver that takes voting rights away from Trump's supporters.
After the initial lawsuit was filed, Newsom responded.
"There's an easy fix Mr. President -- release your tax returns as you promised during the campaign and follow the precedent of every president since 1973," the governor tweeted.
Trump's team of private lawyers has been on the offensive in recent weeks, filing lawsuits to thwart attempts by Democrats to see his tax returns. They've filed a handful of lawsuits in federal courts across the country, mainly to stop House Democrats from seeking the tax returns through the Trump family and the Trump Organization's banks, an accounting firm or under a New York state law.
In court, England noted that while the law covers all presidential candidates, it was aimed at Trump.
"The elephant in the room is President Trump's tax returns," England said.
"Trump spawned this when he broke 50 years of tradition" by not releasing them, argued Peter Chang, a lawyer for California.
A lawyer for Trump, Thomas McCarthy, countered that the law "handicaps" the candidate who wants to keep tax returns private. He also argued the law could create a slippery slope that might lead to more extreme candidate disclosures like mental and physical information.
Mark Albert, another attorney arguing against the law, echoed this sentiment, stating in a tongue-in-cheek riff that eventually presidential candidates would have to release "23 and me" reports detailing their genetics, a reference to the private company that sells DNA kits.