The Trump administration told the Supreme Court on Tuesday that the program shielding young undocumented immigrants brought to the United States as children should end regardless of its legality, and the court’s dominant conservative justices showed no inclination to disagree.

Solicitor General Noel Francisco said the administration thinks the Deferred Action for Childhood Arrivals (DACA) program, which President Barack Obama authorized through executive action in 2012 to protect law-abiding immigrants brought to the United States as children, is unlawful.

But even if it is not, he said, the Department of Homeland Security has the right to terminate it, and its decision to do so is not reviewable by courts.

“DACA was a temporary stopgap measure that, on its face, could be rescinded at any time,” Francisco said in a nearly 1½ -hour oral argument. “And the department’s reasonable concerns about its legality and its general opposition to broad nonenforcement policies provided more than a reasonable basis for ending it.”

It is one of the court’s most important cases of the term, and the court’s four liberal justices indicated the administration had not met requirements for ending a program with such dire consequences for the immigrants and the economy.

But they did not appear to find support from the court’s conservatives, who reserved their toughest questions for those challenging the administration’s actions. Chief Justice John G. Roberts Jr., perhaps the pivotal member of the court, gave no indication that he found the administration’s actions troublesome or unusual.

But questioning at oral arguments is not always predictive, and the decision in the case might not come for months.

The administration, Francisco said, is not advancing a “law made us do it” argument for ending a program with nearly 700,000 recipients, whose lives would be disrupted by the end of promises to forego deportation and allow legal employment.

“We own this,” Francisco said.

The court’s liberal justices said the administration needed more-compelling reasons for ending the program. That was especially true, said Justice Sonia Sotomayor, in light of President Trump’s on-again, off-again signals of support for the “dreamers.”

“There’s a whole lot of reliance interests that weren’t looked at, including . . . the current president telling DACA-eligible people that they were safe under him and that he would find a way to keep them here,” said Sotomayor.

Instead, she continued, the administration’s winding down of the program translated to “I’ll give you six months to destroy your lives.”

The president’s apparent ambivalence was on display early Tuesday, before arguments even began.

“Many of the people in DACA, no longer very young, are far from ‘angels.’ Some are very tough, hardened criminals,” Trump said in a tweet. But then he added: “If Supreme Court remedies with overturn, a deal will be made with Dems for them to stay!”

The president has said a ruling in the administration’s favor is necessary to bring congressional Democrats back to the negotiating table. His remarks about some DACA recipients being criminals contrasts with his usual sympathetic concern for them and is at odds with the program’s requirements

A clean criminal record is a prerequisite. The program is open to those who were brought to the United States before they were 16 years old, have lived in the country at least five years, and have paid for and received a background check. The program does not provide a path to citizenship, but it does allow recipients to work legally and to renew their two-year reprieves from deportation.

A government study found more than 90 percent of recipients, who now are in the 20s and 30s, are employed, and about half are students.

Justice Stephen G. Breyer said more than just the DACA recipients have a stake in the program, as evidenced by an outpouring of briefs in the case asking the court to say the program should continue.

“There are 66 health-care organizations. There are three labor unions. There are 210 educational associations,” Breyer said. “There are six military organizations. There are three home builders; five states plus those involved; 108, I think, municipalities and cities; 129 religious organizations; and 145 businesses.”

Francisco said that even Obama never saw the program as permanent, and recipients were on notice that they must apply every two years and that the benefits afforded them could end. The administration considered all those things, he said.

Lower courts have said that Trump’s decision in 2017 to terminate the program was based on a faulty belief that the program was legally and constitutionally defective, and that the administration has failed to provide reasons for ending it that courts and the public can judge.

Francisco disputed that. While the first memo outlining termination of the program relied exclusively on the view, put forward by Trump’s first attorney general, Jeff Sessions, that the program was illegal, a subsequent DHS memo invited by a judge during the litigation supplied other reasons. There would be no point in requiring the administration to repeat that step, Francisco said.

All that challengers seem to be saying, he said, “is we have to write a few more words.”

But Justices Elena Kagan and Ruth Bader Ginsburg said a presumption about the program’s illegality provides the backdrop for all of the administration’s actions. Francisco relied on the memo from then-DHS Secretary Kirstjen Nielsen that listed reasons other than Sessions’s view that the program was illegal.

“We don’t know how she would respond if there were a clear recognition that there was nothing illegal about DACA,” Ginsburg said.

But the court’s liberals would need one of its five conservatives to agree with them. There was little in their questions to give hope to the two lawyers who argued for the challengers, Washington lawyer Theodore B. Olson and California Solicitor General Michael J. Mongan.

The Trump administration moved to scuttle the DACA program in 2017 after Texas and other states threatened to sue to force its end. Sessions said that the program could not be defended, basing his decision on a ruling by the U.S. Court of Appeals for the 5th Circuit, which said that another Obama program protecting undocumented immigrants was beyond the president’s powers. The Supreme Court deadlocked 4 to 4 in 2016 when considering the issue.

Roberts asked Mongan why those facts wouldn’t be enough for an attorney general to say “we’re not going to do it.”

Justice Brett M. Kavanaugh noted that the memo from Nielsen indicated “that regardless of whether these concerns about the DACA policy rendered it illegal or legally questionable, there are sound reasons of enforcement policy to rescind the DACA policy.”

Justices Neil M. Gorsuch and Samuel A. Alito Jr. wondered if courts had a role in reviewing such judgments of the attorney general and homeland security secretary.

“Whenever a law enforcement agency has guidelines for the exercise of prosecutorial discretion, and it then tightens those guidelines so that cases that previously would not have been prosecuted may now be prosecuted,” that is not up for judicial review, Alito said.

But Olson, arguing on behalf of a coalition of businesses, civil rights groups, universities and individuals, said DACA was different from most programs because the government “invited them into the program,” referring to DACA recipients. Olson, a former solicitor general under President George W. Bush, said the recipients have identified themselves and made their deportation easier if that day should come.

Roberts said deportation was unlikely — the government wouldn’t have the resources to undertake such a mass action. The real issue, he said, was work authorization.

Olson said that despite Francisco’s assertions, the legal advice from Sessions gave DHS no option but to end the program. The court should require the administration to start over and give reasoned arguments for why it is in the country’s best interests to end the program, he said.

But Gorsuch, who said the “sympathetic facts” about DACA recipients “speak to all of us,” wondered what would be the point. “What more would you have the government say?” he asked Olson.

The consolidated cases the court heard Tuesday are Department of Homeland Security v. Regents of the University of California, Trump v. NAACP and McAleenan v. Vidal.