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 judicial review is to be more than an empty ritual, it must demand something better than the explanation offered for the action taken in this case,” Chief Justice Roberts wrote. The evidence that has emerged on Mr. Ross’s decision-making process “tells a story that does not match the explanation the secretary gave,” he wrote.

The Supreme Court’s central holding against the Trump administration came on a 5-to-4 vote, with the chief justice joined by the court’s four liberal justices—Ruth Bader Ginsburg, Stephen Breyer, Elena Kagan and Sonia Sotomayor.

In a pair of tweets after the ruling, President Trump said he asked lawyers if the census could be delayed for now while legal proceedings continue. “Can anyone really believe that as a great Country, we are not able [to] ask whether or not someone is a Citizen. Only in America!” Mr. Trump wrote in one tweet.