WASHINGTON — President Trump proclaimed on Friday that the illegal entry of immigrants across the southern border of the United States was detrimental to the national interest, spurring tough changes that will deny asylum to all migrants who do not enter through official border crossings.

“The continuing and threatened mass migration of aliens with no basis for admission into the United States through our southern border has precipitated a crisis and undermines the integrity of our borders,” Mr. Trump wrote in the proclamation.

As he left the White House for the overseas trip, Mr. Trump said, “We want people to come into our country, but they have to come into the country legally.”

The American Civil Liberties Union filed a lawsuit on Friday within hours of the president’s proclamation, urging a federal judge to prohibit Mr. Trump from moving ahead with his plans to deny asylum to thousands of migrants who may cross the border.

In a legal filing in United States District Court in San Francisco, the A.C.L.U. said that the president’s move was “in direct violation of Congress’s clear command that manner of entry cannot constitute a categorical asylum bar.” The lawsuit also alleges that the administration enacted the rule “without the required procedural steps and without good cause for immediately putting the rule into effect.”

The lawsuit could set in motion another clash between Mr. Trump and the judicial system over the power of the presidency to control the nation’s borders. Officials at the Justice Department and the Department of Homeland Security did not immediately respond to questions about the lawsuit.

Administration officials said on Friday that the suspension of asylum rights would be in effect for at least 90 days, but could end sooner if Mexico’s government would sign an agreement allowing the United States to return those who illegally cross the border from Mexico, regardless of their home country — a proposal that Mexico has long rejected.

For decades, immigration law in the United States has required that officials allow migrants who fear persecution in their home countries to seek asylum regardless of whether they entered the United States legally or illegally.

Mr. Trump’s proclamation is a radical departure from that tradition. With the exception of children arriving without parents, officials said that all migrants who cross illegally would automatically be denied asylum. Advocates for migrants condemned the policy shift as meanspirited and unconstitutional.

“Issuing a presidential proclamation effectively denying vulnerable families protection from violence is contrary to our laws and values,” said Kevin Appleby, a senior director at the Center for Migration Studies. “In the long run, it will not deter asylum seekers who are fleeing for their lives. On this one, the emperor has no clothes.”

Across the world, nations have for years agreed to consider asylum protections for those fleeing violence and persecution, even if they cross borders illegally. Human rights advocates said on Friday that the United States should be a leader in supporting that idea.

“One thing that unites a majority of Americans is a belief in the principle of asylum,” Ali Noorani, the executive director of the National Immigration Forum, said in a statement. “Eroding that principle means eroding a defining value of our nation.”

Administration officials insisted that the new rules would remain consistent with United States obligations to the rest of the world because seeking asylum is not the only way for someone fleeing persecution to receive protection.

Officials said migrants would be allowed to seek other protections if they could prove a risk of being tortured in their home countries. However, they conceded that those claims were purposely much harder to prove and that fewer people were likely to qualify to stay in the United States than would have by receiving asylum. The only way to seek asylum will be to arrive at an official border crossing.

But officials conceded that many of the crossings from Mexico into the United States — known as ports of entry — were over capacity and already had trouble processing the number of asylum claims being made by migrants there. Under the new policy, many more are expected to arrive at the crossings.

In the proclamation, Mr. Trump acknowledged the problem and directed his administration “to commit additional resources to support our ports of entry at the southern border to assist in processing those aliens.”

Mr. Trump’s proclamation drew on the same powers to control the nation’s borders that he cited when he banned travel from several predominantly Muslim nations shortly after becoming president. The Supreme Court upheld a later version of that ban after a nearly year-and-a-half legal fight.

The new proclamation is certain to ignite a similar legal battle.

For months before the midterm elections, Mr. Trump cast the group of migrants as a threat to national security, claiming — without evidence — that among them are criminals and “unknown Middle Easterners.”

Mr. Trump’s proclamation puts into effect regulatory changes announced Thursday afternoon that effectively overhaul deep-rooted asylum laws that sought to provide a safer life in America for people fleeing violence and persecution in their home countries. Officials said the changes would take effect early Saturday morning.

Most of the migrants in the caravan come from Honduras and other Central American nations, where they say they fear for their lives because of continuing violence.

Mr. Trump has been seething for months about the increase of immigrants crossing into the United States from Mexico and the caravan of several thousand migrants whose travels have drawn news media attention. The president ordered more than 5,000 active-duty troops to the border to prevent the migrants from crossing.

By early this week, that caravan still had about 4,000 or 5,000 people and had made it to Mexico City.

A version of this article appears in print on , on Page A12 of the New York edition with the headline: Trump Suspends Asylum Rights for Everyone Entering the U.S. Illegally. Order Reprints | Today’s Paper | Subscribe