Washington (CNN) President Donald Trump retreated from his quest to add a question about US citizenship to the 2020 census on Thursday, instead asking government agencies to provide records that could determine a head-count of citizens without polling census-takers directly.

The turnaround comes after Trump repeatedly said he would continue fighting to insert the question despite a Supreme Court ruling that dealt a blow to the effort last month. It reflects legal reality intersecting with Trump's desire to bolster his image as an immigration hard-liner as he moves ahead with his 2020 reelection bid.

Instead of attempting to put the question on census forms, or adding it separately, Trump issued an executive order directing the Commerce Department to obtain citizenship data through means other than the census. That includes documents from the Department of Homeland Security, which houses citizenship and asylum services, and the Social Security Administration

The order was signed and released to reporters late Thursday night. The Justice Department notified federal district judges of the administration's decision.

Trump repeatedly said in Rose Garden remarks that he was not backing away from attempting a count of US citizens, but acknowledged legal setbacks in inserting a citizenship question on the nationwide population survey.

"We are not backing down on our effort to determine the citizenship status of the US population," Trump said in laying out his plan.

Still, the announcement reflected a setback in the President's bid to cement his reputation as an immigration hawk. Trump believes the immigration matter remains a potent force in his popularity among conservative voters, and hopes to further solidify his position in the year-and-a-half before he faces reelection.

His continued battle to include the citizenship question on the census -- risking another Supreme Court denial -- came as federal law enforcement agents prepared for nationwide raids on undocumented immigrants.

In announcing the decision, Trump insisted he would be unrelenting in seeking out citizenship information from alternate sources. He said agencies would be required to provide the Commerce Department with documents and records of citizens and non-citizens, which he said would help provide an accurate picture of US citizenship.

"We will leave no stone unturned," Trump said. He did not accept questions during the event, which occurred under cloudy skies before an audience of right-wing online personalities.

Speaking after Trump, Attorney General William Barr cast the decision as one of legal practicality rather than of ideological shift.

"There is simply no way to litigate these issues and obtain relief from the current injunctions in time to implement any new decision without jeopardizing our ability to carry out the census," Barr said, noting that it was "a logistical impediment, not a legal one."

Barr noted the Supreme Court determined that including a citizenship question would not, in itself, be unconstitutional, ruling instead the "Commerce Department did not adequately explain its decisions for doing so on the 2020 census."

Commerce Secretary Wilbur Ross, who has been the subject of Trump's frustration for his handling of the census issue, stood nearby as Barr spoke but did not approach the microphones himself.

Constructing a file of citizenship data through so-called administrative records was one of the original recommendations from career Census Bureau leadership when Ross asked the bureau to consider adding the citizenship question.

In a January 2018 memo, the Census Bureau considered three ways to respond to the Justice Department's request that the question be asked and citizen voting age population data be collected: Do nothing, add a citizenship question to the census, and "obtaining citizenship status from administrative records for the whole 2020 Census population."

The bureau recommended Ross choose the administrative records option, calling it higher quality than self-reported data and significantly less expensive. The cost "is very likely to be less than $2M (million)," while adding a citizenship question could increase costs "by at least $27.5 million," a Census Bureau memo to Ross read.

Nevertheless, Ross went forward with adding the question in addition to instructing the agency to compile administrative records.

The Supreme Court late last month blocked the citizenship question from being added to the 2020 census. The bitter controversy centered around whether the administration can ask all recipients a citizenship question on the 2020 census for the first time since 1950 -- a move that could have impacted the balance of power in states and the House of Representatives, which are based on total population.

Adding the question, critics say, would result in minorities being undercounted by scaring off even legal residents or naturalized citizens from completing the decennial questionnaire, which is also used to determine funding for an array of government programs.

Key Republican senators said early Thursday they had not been briefed by the White House on the contours of Trump's action. Senate Commerce Committee Chairman Roger Wicker, a Republican from Mississippi who has oversight of the Census Bureau, said he has not had discussions with the White House.

Asked Thursday if she was happy about Trump's decision not to press forward with an effort to add the citizenship question to the census, House Speaker Nancy Pelosi told CNN: "Not happy. Jubilant."

"If he had tried to defy the Supreme Court, that would've been a constitutional crisis," Pelosi said. "So for the basis of the census and the citizenship question, I'm glad it's gone. For the basis of the country I'm glad that he was advised" not to try another route to add the question to the census.

Some type of direct action by Trump had been one of several avenues explored by the administration to place the question on the population survey following the late June Supreme Court ruling.

The Trump administration initially announced printing would go forward without the citizenship question. Government attorneys had asserted to the courts that the printing process -- either with or without the question -- needed to begin on July 1 to avoid extra costs.

That approach was thrown into disarray when Trump abruptly changed course last week , ordering officials to find another way to add the question -- something the Supreme Court left the door open to in its ruling. White House and Justice Department officials spent the Independence Day holiday considering ways to include the question.

One unanswered question was how the administration would implement the addition of the question to the census forms after printing had begun. Options included reprinting the forms that have been printed without the question, or printing a supplemental page.

Critics of the administration's attempt to use the census to poll citizenship were victorious on Thursday.

"Trump's attempt to weaponize the census ends not with a bang but a whimper," said Dale Ho, director of the American Civil Liberties Union's Voting Rights Project, who argued the Supreme Court case.

The issue still faces ongoing action in the lower courts.

There is already a motion asking federal Judge Jesse Furman in New York to totally prohibit the administration changing the census or adding the question in any way. A Census Bureau official said during a trial last year that the form could be finalized after June, and as late as October, but only if "exceptional resources" were provided. He did not specify a dollar figure.

Legal maneuvering is expected to stretch through the summer in two federal trial courts. The New York court is set to hear arguments from critics of the question that the government should be sanctioned. In Maryland, a judge recently reopened the trial after an ACLU-led group presented what they say is new evidence the question was proposed with discriminatory motives. A hearing on the evidence is scheduled for after the Labor Day weekend. The challengers to the question said Thursday evening that they wouldn't be dropping their cases.

This story has been updated.