U.S. President Donald Trump speaks with the news media, with first lady Melania Trump standing beside him, before boarding Marine One for travel to Europe from the White House, in Washington, U.S., July 10, 2018. REUTERS/Leah Millis

WASHINGTON (Reuters) - U.S. President Donald Trump on Tuesday pushed back against court rulings against his administration’s migrant detention policies, saying immigrants should not come to the United States illegally.

“I have a solution: Tell people not to come to our country illegally. That’s the solution,” Trump told reporters at the White House a day after a U.S. federal judge rejected long-term detention of illegal immigrant children. “Come legally.”

“We have laws. We have borders. Don’t come to our country illegally. It’s not a good thing,” he added.

On Monday, U.S. District Court Judge Dolly Gee in Los Angeles dismissed the U.S. Justice Department’s request to allow long-term detention for children who entered the United States illegally. The department had sought to modify a 1997 settlement allowing such children to be held for up to 20 days.

The Trump administration is struggling to unite immigrant families that it separated at the U.S.-Mexico border after another U.S. judge in San Diego last month ordered them to be reunited as soon as Tuesday.

The children had been separated starting in early May under Trump’s “zero tolerance” policy, which called for the prosecution of immigrants crossing the border illegally. But Trump halted the practice last month after intense criticism.

(Corrects typographical error in 2nd paragraph to make it “country” instead of “county”.)