Later that day, Judge William Alsup of Federal District Court in San Francisco handed down his ruling, writing that the administration must “maintain the DACA program on a nationwide basis” as the legal challenge to the president’s decision goes forward.

In his ruling, Judge Alsup laid out a road map for the government that officials appeared to follow. He said that previous beneficiaries of DACA, known as Dreamers, must be allowed to renew their status in the program, though the government would not be required to accept new applications from immigrants who had not previously submitted one.

On Sunday morning, Mr. Trump blamed Democrats for preventing progress on a legislative deal that would permanently legalize the young immigrants and give them an eventual path to citizenship in exchange for tougher border security and enforcement measures.

The president criticized Democratic lawmakers, some of whom have suggested that they will not support efforts to fund the government by a deadline later this week unless Congress passes the DACA legislation.

“DACA is probably dead because the Democrats don’t really want it, they just want to talk and take desperately needed money away from our Military,” Mr. Trump said on Twitter from his Mar-a-Lago estate in Palm Beach, Fla.

In a second tweet, Mr. Trump said that immigration legislation should include an end to the diversity visa lottery system, in which the State Department encourages diversity in immigration by holding a lottery for those wanting to come to the United States.

The president has criticized the program as a threat to the country’s security even though people selected are screened in the same ways that other immigrants are. Mr. Trump has also said that the program undermines efforts by the administration to allow immigrants who have skills that will be beneficial to the United States.

“I, as President, want people coming into our Country who are going to help us become strong and great again, people coming in through a system based on MERIT,” he said. “No more Lotteries! #AMERICA FIRST.”