A question about citizenship status will be added to the 2020 US census, for the first time since 1950.
US officials say the move will help the federal government enforce the Voting Rights Act and give it the data it needs to allocate resources.
But the move has proved controversial, amid concerns migrants may not take part as they would fear the information could be used against them.
California's attorney general has said he will try to block the move.
A census is mandated under the US constitution and takes place every 10 years, counting every resident in the country.
The data is collected to help the federal government calculate the distribution of funding and draw up district maps to be used at state and local elections.
President Donald Trump has argued, without providing evidence, that millions of illegal immigrants voted in the 2016 presidential election.
The commerce department, which oversees the census, said it had added the question after a request from the justice department.
Commerce Secretary Wilbur Ross said that the Voting Rights Act required a tally of citizens of voting age to ensure that minority groups were not discriminated against.
He said that even if the citizenship question had an effect on responses, "the value of more complete and accurate data derived from surveying the entire population outweighs such concerns".
Opponents of a citizenship question fear it could be used to target undocumented migrants
Opponents of placing a question about citizenship include the state of California and many interest groups representing migrants.
California Attorney General Xavier Becerra asked a US court to place an injunction on the question.
Mr Becerra said it violated the US constitution, as those who are undocumented migrants would fear coming forward and so would stop the federal government from being able to conduct a full count of the US population.
Kristen Clarke, president of the Lawyers' Committee for Civil Rights Under Law, told the Reuters news agency the question was in line with "xenophobic and anti-immigrant policy positions from [the Trump] administration".
Carolyn Malone, a Democrat who represents part of New York City, said the move was "politically motivated" as it could strengthen the Republican Party's position in future elections.
Questions on citizenship have appeared in the past, but not on the more frequent population surveys the census bureau carries out.