The U.S. Supreme Court on Thursday ruled that adding a citizenship question to the 2020 census is constitutional, but rejected the Trump administration’s arguments for adding it and asked the Commerce Department for further explanation. It returned the case to a New York federal court, which had barred the question.

The ruling blocks the question for now and was at least a temporary victory for Pennsylvania, New Jersey, and dozens of other state and local governments that said the question would deflate their population counts by millions of people, costing them political power and billions of dollars in federal funding.

The Trump administration had argued it needed the question about citizenship status to bolster the Voting Rights Act, intended to protect minority voters.Commerce Secretary Wilbur Ross, whose department oversees the census, pursued the question over objections from the Census Bureau, which said it would likely increase costs and lower response rates in households with non-citizens and immigrants.

The bureau said Thursday it was reviewing the decision.

The justices ruled that “unlike a typical case in which an agency may have both stated and unstated reasons for a decision, here the [Voting Rights Act] enforcement rationale — the sole stated reason — seems to have been contrived.”

The question has become the source of a deeply partisan debate, since areas most at risk of an undercount are communities with large Latino and immigrant populations, which lean Democratic, and the decision comes at the start of the presidential campaign cycle. Democratic presidential candidates hailed the high court’s action.

President Donald Trump tweeted Thursday: “Seems totally ridiculous that our government … cannot ask a basic question of citizenship.” He said he had asked his lawyers if they can delay the census “no matter how long” until the Supreme Court "can make a final and decisive decision.” The Census Bureau plans to count the population as it exists as of April 1, 2020; April 1 has been the population reference point every decade since 1930.

The decision to add a citizenship question requires “reasoned decision-making,” Chief Justice John G. Roberts Jr. wrote in the court’s majority opinion. “What was provided here was more of a distraction."

Miguel Andrade, a spokesperson for Philadelphia-based immigrants-rights organization Juntos, said the justices’ decision is "a good indication they’re seeing through to the real reason the administration really wants to add this question.” Juntos and other immigrant advocacy groups believe the administration wants to use it to suppress immigrants’ political influence and deny resources to communities with large noncitizen populations.

>>READ MORE: Timeline to the Supreme Court’s ruling on the citizenship question in the 2020 Census

Pennsylvania is home to about 870,000 noncitizens, roughly 3.3 percent of the population, according to the Attorney General’s Office. More than 260,000 noncitizens live in the Philadelphia region, including 106,000 in the city, according to census estimates.

In New Jersey, about 2 million people are foreign-born, more than one-fifth of the population; nationwide, the state has the third-highest percentage of immigrants, behind California and New York.

The Supreme Court was tasked with deciding whether the citizenship question violated a constitutional mandate to count all residents and whether the commerce secretary misused his authority. A case arguing that the question should be blocked because it is racially discriminatory against Latinos and Latinas remains unresolved in a federal case in Maryland.

Last month, the New York Times reported that the computer hard drives of a deceased political strategist showed the administration’s decision to add the question was part of a plan to help elect Republicans.

The files showed that Republican strategist Thomas Hofeller wrote a 2015 study that found that adding a citizenship question would lead to more Republican-friendly congressional districts, the Times reported.

The newspaper said the disclosures represent the “most explicit evidence to date that the Trump administration added the question to the 2020 Census to advance Republican Party interests.” Federal judges in New York and Maryland are reviewing the allegations.

Population tallies in each decennial census determine the disbursement of hundreds of billions of dollars in federal funds to local governments, the boundaries of voting districts, the number of votes that states get in the Electoral College, and each state’s share of seats in the U.S. House of Representatives.

Mayor Jim Kenney and Stephanie Reid, executive director of Philly Counts 2020, said in a joint statement that they hoped the court’s decision "will result in the rejection of any new, contrived reasoning from the Trump administration as they attempt to push through a question that is aimed at suppressing full participation of immigrants across the country.”

New Jersey Attorney General Gurbir S. Grewal called the decision “a big win.” Pennsylvania Attorney General Josh Shapiro said the Supreme Court saw the Trump administration’s reason for adding the question “for what it really is — a sham.”

The U.S. Department of Justice said it was “disappointed” by the ruling and "will continue to defend this administration’s lawful exercises of executive power.”

Federal judges in New York, Maryland, and California challenged the administration’s stated motives and ruled against the question. The California judge also said the addition of the question was unconstitutional.

The dispute started in early 2018, when Ross announced that the 2020 Census would include a question on citizenship: “Is this person a citizen of the United States?”

The government asserted that citizenship or country-of-birth questions of some sort had been posed to at least a sample of people in all but one census from 1820 to 2000. The last time the government asked every household for members’ citizenship status was in 1950.

In April 2018, Shapiro and Grewal joined a coalition of 16 other state attorneys general; six city governments, including Philadelphia’s; and the bipartisan U.S. Conference of Mayors in filing a lawsuit to block the Trump administration from asking the citizenship question in the census.

Pennsylvania gets roughly $2,100 per person in federal funds based on census numbers, and New Jersey roughly $1,960, according to a 2017 report by the George Washington Institute of Public Policy.

In January, a federal court in New York barred the government from including the question. The Supreme Court agreed to consider the appeal in an expedited time frame and heard arguments in April. The Census Bureau said it needed an answer by July 1 in order to get forms and other mailings printed in time for next year’s count, which begins in March.

Six former directors of the Census Bureau, who served in both Republican and Democratic administrations, signed a letter saying that adding a question on citizenship so late in the process “would put the accuracy of the enumeration and success of the census in all communities at grave risk.”