HOUSTON -- A federal judge on Friday declined to order that the U.S. government halt an Obama-era program that shields young immigrants from deportation. The decision is a blow to President Trump and other opponents of the Deferred Action for Childhood Arrivals (DACA) program.

U.S. District Judge Andrew Hanen said Texas and six other conservative states that sued to block DACA couldn't prove that allowing the program to continue was causing irreparable harm. The judge questioned the legality of DACA but argued that more harm would be done to DACA recipients if they lost the program.

The judge, who has ruled against DACA-related programs in the past, essentially said the states waited too long to ask for the preliminary injunction.

Get Breaking News Delivered to Your Inbox

"Here, the egg has been scrambled. To try to put it back in the shell with only a preliminary injunction record, and perhaps at great risk to many, does not make sense nor serve the best interests of this country," Hanen wrote in his ruling.

But he reiterated that he believes DACA as enacted by former President Barack Obama is unconstitutional.

"If the nation truly wants to have a DACA program, it is up to Congress to say so," Hanen wrote.

The states filed the lawsuit in Texas, hoping Hanen would stop DACA recipients from continuing to renew their enrollment. That would have triggered a conflict with three federal orders that have required the U.S. government to keep accepting DACA renewals, even after Mr. Trump tried to end the program last year. Legal experts say such a conflict would have drawn the attention of the U.S. Supreme Court.

The U.S. Department of Justice released a statement Friday commending the judge for addressing the legality of the program.

"As the Justice Department has consistently argued, DACA is an unlawful attempt to circumvent Congress, and we are pleased the court agreed today," spokesman Devin O'Malley said.

With the Trump administration now opposing the program, some states that support DACA - along with the Mexican American Legal Defense and Educational Fund, or MALDEF - intervened in the lawsuit to defend it.

The lawsuit followed the same strategy that stopped an expansion of DACA also proposed by the Obama administration. After Mr. Obama announced he would create a program protecting the parents of children in the U.S. without legal permission, Texas sued in federal court in Brownsville, Texas, where Hanen is based.

Hanen ended up with that case and ruled the expansion of protections was unconstitutional. In that case, an appeals court upheld his ruling, and the Supreme Court split 4-4 after the death of Justice Antonin Scalia, leaving the ruling in place.

On Friday, Texas Attorney General Ken Paxton said he was confident the courts would ultimately find DACA unconstitutional. He said an injunction was denied only because the states waited too long to request it.

Texas was joined in filing the lawsuit by Alabama, Arkansas, Louisiana, Nebraska, South Carolina and West Virginia. The states argued that Mr. Obama, as president, never had the authority to create a program like DACA because it circumvented Congress.

The state also cited costs to educate immigrants, which lawyers for MALDEF argued were "both irrelevant and grossly inflated." The group also said that unlike the program Hanen struck down, which never went into effect, DACA has allowed hundreds of thousands of people to work and pay taxes in the six years since it started. That, the group argued, benefits federal and state governments.

MALDEF said it was happy with the decision and expects the states to appeal to a higher court.

"Today DACA beneficiaries like myself and my little sister breathe a sigh of relief. We all know DACA works," said Greisa Martinez Rosas, the deputy executive director of United We Dream.