WASHINGTON — For months, an anxious and uncertain President Trump was caught between opposing camps in the West Wing prodding him to either scrap or salvage an Obama-era program allowing undocumented immigrants brought to the country as minors to remain in the United States.

Last week, with a key court deadline looming for Deferred Action for Childhood Arrivals, or DACA, Mr. Trump, exasperated, asked his aides for “a way out” of a dilemma he created by promising to roll back the program as a presidential candidate, according to two people familiar with the exchange.

Mr. Trump’s chief of staff, John F. Kelly, who had wrestled with crafting a compromise in his previous job as the president’s homeland security secretary, began consulting with Republican lawmakers and staff members for a quick fix, according to three officials familiar with the situation. He finally arrived at an inelegant solution to an intractable problem: Delaying a decision on the final fate of about 800,000 “Dreamers” covered by President Barack Obama’s executive action for six months, and putting it on Congress to come up with a legislative solution to the problem.

Congressional Republicans expect the administration to unveil some version of this stopgap solution on Tuesday, but Mr. Trump will not make the announcement himself. Instead, Attorney General Jeff Sessions will handle it at an 11 a.m. briefing. He will not take questions from reporters.