President Donald Trump has made cracking down on illegal immigration a key part of his first-term agenda.

President Donald Trump, facing renewed criticism from Democrats and activists over his handling of a migrant crisis on the U.S.- Mexico border, said in a Twitter post on Wednesday that immigrants unhappy with conditions at detention centers should be told "not to come."

Democratic lawmakers and civil rights activists who have visited migrant detention centers along the border in recent days have described nightmarish conditions marked by overcrowding and inadequate access to food, water and other basic needs.

The Department of Homeland Security's inspector general on Tuesday published photos of migrant-holding centers in Texas' Rio Grande Valley crammed with twice as many people as they were meant to hold.

"If Illegal Immigrants are unhappy with the conditions in the quickly built or refitted detentions centers, just tell them not to come. All problems solved!" Trump said on Twitter.

The Republican president has made cracking down on illegal immigration a key part of his first-term agenda after campaigning on the issue ahead of the 2016 election.

"Our Border Patrol people are not hospital workers, doctors or nurses," Trump wrote earlier on Twitter. "Great job by Border Patrol, above and beyond. Many of these illegals (sic) aliens are living far better now than where they ... came from, and in far safer conditions."

Criticism of the U.S. Customs and Border Protection agency grew after reports this week that current and former agents had posted offensive anti-immigrant comments and targeted lawmakers on their private Facebook group.

Acting Department of Homeland Security chief Kevin McAleenan on Wednesday ordered an investigation into the posts, calling the comments "disturbing."

The Facebook posts, first reported by ProPublica, included jokes about immigrants dying and sexually explicit content about U.S. Democratic Representative Alexandria Ocasio-Cortez, who criticized the detention facilities after a tour this week.

Democratic Senate Minority Leader Chuck Schumer called for the acting head of the CBP and other top leaders at the agency to be fired.

Democratic U.S. Representative Joaquin Castro said after a visit to the border this week that detainees had been not been allowed to bathe for two weeks, were deprived of medication and locked in areas with broken water faucets.

"It's clear that their human rights were being neglected," the Texas lawmaker told reporters in a conference call.

Court battles

The White House on Wednesday sharply criticized a ruling by a federal judge in Seattle who blocked its attempt to keep thousands of asylum seekers in custody while they pursued their cases.

"The decision only incentivizes smugglers and traffickers, which will lead to the further overwhelming of our immigration system by illegal aliens," White House press secretary Stephanie Grisham said in a statement.

The American Civil Liberties Union and immigrant rights groups sued the government in April after Attorney General William Barr concluded that asylum seekers who entered the country illegally were not eligible for bond.

Congress has blocked Trump's efforts to fund construction of a wall on the southern border, and the 9th U.S. Circuit Court of Appeals in San Francisco refused on Wednesday to lift an injunction barring the administration from using $2.5 billion intended to fight narcotics trafficking to build the barrier.

But the record surge of mostly Central American families, fleeing crime and poverty at home, has begun to ease after tougher enforcement efforts in Mexico, according to officials from both countries.

Mexico's government, citing unpublished U.S. data, said border arrests fell 30% in June from May after a crackdown as part of a deal with the United States to avoid trade tariffs.

The Mexican government said it was busing home Central American migrants from Ciudad Juarez who had been forced to wait in Mexico for their asylum claims to be processed under a U.S. policy known as "Remain in Mexico."

Biggest political issue

Since migrant arrests reached a 13-year monthly high in May, immigration has arguably become the biggest issue for Trump and Democratic presidential contenders vying for the right to face him in the November 2020 election.

"Mexico is doing a far better job than the Democrats on the Border. Thank you Mexico!" Trump said Wednesday on Twitter.

U.S. Senator and Democratic presidential candidate Cory Booker spent much of the day on the Mexican side of the border in Ciudad Juarez, meeting with migrants who had been sent back to Mexico to await their asylum hearings under a new Trump administration policy.

Booker escorted five women believed to be fleeing domestic abuse across the bridge over the Rio Grande and to the border port of entry in El Paso, Texas, according to a Facebook video he posted. Booker said they had been unfairly returned back when they should have been accepted by U.S. authorities.

"I'm going to fight for these five folks and do everything I can to see that they be fairly evaluated," Booker told reporters.

Democratic presidential hopeful Julian Castro, Joaquin Castro's brother, last week proposed decriminalizing border crossings as a step toward freeing up federal resources and eliminating thousands of immigration cases clogging criminal courts.