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 -- England, a George W. Bush appointee, signaled he was inclined to rule in favor of Trump.
California Secretary of State Alex Padilla announced Tuesday that he plans to appeal the judge's decision.
"California will appeal this ruling and we will continue to make our thorough, thoughtful argument for stronger financial disclosure requirements for presidential and gubernatorial candidates," Padilla said in a statement, adding that the law is "fundamental to preserving and protecting American democracy."
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 in 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 in August 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 last month, 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.
CORRECTION: This story has been corrected to reflect that the second similar lawsuit filed by Republicans in California was filed in August.