WASHINGTON—A deeply divided Supreme Court halted the Trump administration’s plans to ask U.S. residents on the 2020 census whether they are citizens, in a ruling Thursday that voiced blunt concerns about the White House’s motivations.

The court, in a strongly worded opinion by Chief Justice John Roberts, said Commerce Secretary Wilbur Ross, who made the decision to add a citizenship question, hadn’t explained his real reasons for doing so, leaving the legality of his actions in question.

“If...