It could mean news coverage of the government trying to deport thousands of young immigrants in the midst of what is certain to be a difficult re-election battle.

Credit...Erin Schaff/The New York Times

President Trump may find himself in a political box of his own making when the Supreme Court rules on the fate of the Deferred Action for Childhood Arrivals program.

If the court decides that the administration has the right to end the program, known as DACA, Mr. Trump will face a consequence he has tried to put off for years: news coverage of efforts by the government to deport thousands of young immigrants in the midst of what is certain to be a difficult re-election battle.

In oral arguments on Tuesday, Chief Justice John G. Roberts Jr. suggested that there could be extensive human cost to overturning the program, and that it would need to be mitigated. Still, a ruling that supports the administration’s position sets up a situation in which Mr. Trump — who at times has praised the program and at others condemned it — will face potentially treacherous crosswinds.

The president, who is often pulled by what he thinks his supporters who oppose both legal and illegal immigration might want, has vowed to keep a campaign promise to end DACA, one of President Barack Obama’s singular efforts. At the same time, Mr. Trump has tried to argue that it would not be his fault that the program ended, but the Supreme Court’s.

Based on comments by Chief Justice Roberts and other conservative justices, the court seems poised to let it happen. But the solicitor general, Noel J. Francisco, put perhaps an unintended fine point on the issue for the Trump administration when he told the court on Tuesday, “We own it.”

That might end up being the problem for Mr. Trump, if he has any hope of peeling off support from Latinos and from voters who have recoiled at the administration’s more aggressive immigration policies, like border separations.

Charlie Dent, a former moderate Republican congressman from Pennsylvania and a CNN commentator, said that Mr. Trump would have “bad options or bad outcomes” unless the court ruled that the program was legal.

“I think he’s in a bind politically,” said Mr. Dent, who retired last year. “These young people will be at risk for being thrown out.”

He said that Mr. Trump’s aides might “think they can rally up their base on this thing.” But it is at a cost with the broader population, Mr. Dent added.

Officials with the White House and the Trump campaign did not respond to an email seeking comment.

But Mr. Trump is aware of the politics and how poorly it may play out for him if young immigrants are facing deportation before the 2020 election, according to people close to the White House.

Even when he was ordering Jeff Sessions, the attorney general at the time, to find a solution to DACA, Mr. Trump was asking close aides how he could get out of the political jam he found himself in.

“Presumably, there will be discretion about how aggressively various laws are enforced,” said Whit Ayres, a Republican pollster, “but it does create a political challenge because, consistently, 80 percent of Americans have supported allowing the DACA kids to stay.”

Geoff Garin, a Democratic pollster who has worked for the pro-immigration group FWD.us, said that ending DACA helped reinforce the negative feelings about Mr. Trump’s immigration policies.

“We know from polling that Americans overwhelmingly support DACA. They oppose Trump’s efforts to terminate DACA,” Mr. Garin said. “It reinforces all the other negatives that Trump has established.”

The program, which was announced by Mr. Obama in 2012, lets young people brought to the United States as children apply for a temporary status that lasts two years and can be renewed. It does not offer a pathway to citizenship, something that Mr. Trump’s most hard-line supporters are against.

A national survey by Mr. Garin’s firm of 1,202 voters conducted at the end of the summer showed that 76 percent of all voters said they supported the DACA program. That included 41 percent who strongly supported it, according to a memo the firm wrote. Among a demographic that has supported Mr. Trump, white working-class voters without a college degree, there was support from 70 percent of the group, according to Mr. Garin’s survey.

Mark Krikorian, an immigration restrictionist and the executive director for the Center for Immigration Studies, said that Mr. Trump could theoretically defer making a decision during the election year. With such a move, Mr. Trump’s White House could say the administration will stop processing renewals of DACA status so that it does not kick in until after the election.

“In the middle of an election year, I think the White House can genuinely say that this is not a good time to broker an immigration deal, not for anyone,” Mr. Krikorian said. “That’s a plausible position for them that may limit the political challenge that they face” by ending the program immediately.

The Supreme Court’s decision will also reinforce the challenge any discussion of an immigration deal faces in Congress, even as Mr. Trump’s son-in-law and senior adviser, Jared Kushner, has tried to push through a broader frame for an immigration compromise. However, White House officials said that they were aware that any broad deal would be difficult to push through right now.

“What’s so frustrating is that 80 percent of Americans also support a secure border, and Congress has thus far seemed unable to put those two 80 percent issues together in a very limited immigration bill,” Mr. Ayres said.

Mr. Dent agreed that Mr. Trump “had an opportunity for real compromise over the last few years” on immigration issues. “He just couldn’t get there” with all the cross pressures, Mr. Dent said.