A federal judge in New York on Tuesday barred the Trump administration from adding a question about citizenship to the 2020 census.

U.S. District Judge Jesse Furman ruled that while a question on citizenship would be constitutional, U.S. Commerce Secretary Wilbur Ross had added it arbitrarily and did not follow proper procedure. The ruling comes after a three-week trial in November.

“Secretary Ross’s decision to add a citizenship question to the 2020 census — even if it did not violate the Constitution itself — was unlawful for a multitude of independent reasons and must be set aside,” he wrote.

Among other things, the judge said, Ross didn't follow a law requiring that he give Congress three years notice of any plan to add a question about citizenship to the census. The ruling came in a case in which a dozen states or big cities and immigrants' rights groups argued that the Commerce Department, which designs the census, had failed to properly analyze the effect the question would have on immigrant households.

DEMS DECRY 'CRAVEN ATTACK ON OUR DEMOCRACY,' OVER CITIZENSHIP QUESTION ON CENSUS

Other civil rights groups, like the American Civil Liberties Union, applauded the court’s decision.

“This ruling is a forceful rebuke of the Trump administration’s attempt to weaponize the census for an attack on immigrant communities,” director of the ACLU’s Voting Rights Project, Dale Ho, said in a statement. “The inevitable result would have been – and the administration’s clear intent was – to strip federal resources and political representation from those needing it most.”

The Justice Department said it was "disappointed" by the ruling and is "still reviewing" it.

"Secretary Ross, the only person with legal authority over the census, reasonably decided to reinstate a citizenship question on the 2020 census in response to the Department of Justice's request for better citizenship data, to protect voters against racial discrimination," Justice Department spokeswoman Kelly Laco said in a statement. "Our government is legally entitled to include a citizenship question on the census and people in the United States have a legal obligation to answer. Reinstating the citizenship question ultimately protects the right to vote and helps ensure free and fair elections for all Americans."

The Commerce Department, last May, said in a statement that the citizenship question would be added to the 2020 census count in response to a request made by the Justice Department in December 2017. The statement said that Ross had “determined that reinstatement of a citizenship question on the 2020 decennial census questionnaire is necessary to provide complete and accurate census block level data.”

A separate suit on the same issue, filed by the state of California, is underway in San Francisco.

The U.S. Supreme Court is also slated to address the issue next month.

TRUMP SAYS 'DRONE FLYING AROUND' WILL NOT STOP NEW MIGRANT CARAVAN: 'ONLY A WALL' 

The census count is required by the Constitution, and its results are used to determine federal spending, as well as the number of congressional seats allocated to each state for the next decade, as well as the number of electoral votes available from each state.

Republicans largely supported the additional census question as a logical step. Democrats said the inclusion of such a question amounts to an effort to intimidate immigrant communities and siphon money and electoral power away from them.

But last year, the Commerce Department said that almost every decennial census between 1820 and 1950 “asked a question about citizenship in some form.” The department also said the citizenship question would be “the same as the one that it asked on the yearly American Community Survey (ACS),” which is sent to a much smaller percentage of American homes that the actual census.

CLICK HERE TO GET THE FOX NEWS APP

“The citizenship data provided to the [Department of Justice] will be more accurate with the question than without it,” Secretary Ross wrote in May. “Which is of greater importance than any adverse effect that may result from people violating their legal duty to respond.”

Fox News' Jake Gibson, Kathleen Foster and The Associated Press contributed to this report.