NEW YORK (Reuters) - The Trump administration must face a lawsuit by states and advocacy groups over its plan to ask people who are filling out the 2020 census form whether they are U.S. citizens, a federal judge ruled on Thursday.

FILE PHOTO: An attendee holds her new country's flag and her naturalization papers as she is sworn in during a U.S. citizenship ceremony in Los Angeles, U.S., July 18, 2017. REUTERS/Mike Blake/File Photo

U.S. District Judge Jesse Furman in Manhattan denied the administration’s motion to dismiss the lawsuit, which is backed by 18 states and the District of Columbia.

Furman said in Thursday’s decision that while Commerce Secretary Wilbur Ross had the authority to add the question, which was included in the census prior to 1960, he may have wielded it improperly.

A Commerce Department spokesman said in a statement that the department was “pleased the court found that Secretary Ross has broad authority over the Census,” and was “confident” it would ultimately prevail in the case.

“Today’s decision is a big win for New Yorkers and everyone across the country who cares about a fair and accurate census,” New York Attorney General Barbara Underwood, who led the states in the lawsuit, said in a statement.

The states, cities and organizations seeking to block the question have said it could lead to undercounting in states with large immigrant populations, jeopardizing their political representation and access to federal funds.

They said an “unprecedented level of anxiety in immigrant communities” under President Donald Trump, a Republican who has vowed to crack down on illegal immigration, could deter noncitizens from responding to the census.

The Commerce Department said in March that Ross decided to add the citizenship question after the Department of Justice requested it, in order to better enforce federal voting law.

Furman said in Thursday’s decision that there was evidence that Ross’s stated reason was “pretextual.”

The census, mandated by the U.S. Constitution, is conducted every 10 years and counts every resident in the United States.

It is used to determine the distribution of billions of dollars in federal funds to local communities and the allocation to states of seats in the U.S. House of Representatives.

All of the states involved in the lawsuit have Democratic attorneys general, and the cities have Democratic mayors. The United States Conference of Mayors, a bipartisan group, is also a plaintiff.

Immigrant rights groups said the question violated the Constitution and was motivated by racial animus against Latinos and other immigrants.

Furman said that claim was “plausible” in light of Trump’s derogatory public statements about immigrants, including one referring to “these people from shithole countries.”