EL PASO — The Biden administration is preparing to lift an emergency health rule that has been used to prevent hundreds of thousands of migrants from entering the United States, setting the stage for what could be a new immigration surge that inflames political tensions and strains resources across the southern border.

Barring a last-minute legal challenge, the Trump-era policy known as Title 42 will expire at 11:59 p.m. Eastern on Thursday. It was put in place three years ago under the premise of preventing the spread of Covid-19.

Border agents, state and local officials and even President Biden’s top aides in Washington are all bracing for the arrival of tens of thousands of migrants in the coming days. Already, people have begun crossing into U.S. border towns, anticipating the end of Title 42, which since 2020 has allowed the government to swiftly expel citizens of several countries back to Mexico.

Three cities in Texas — Brownsville, Laredo and El Paso — have declared a state of emergency. Outside the Sacred Heart Catholic Church in downtown El Paso last week, a tableau of human misery fanned out for several blocks, with destitute migrants occupying every spit of sidewalk.

In just days, the numbers there have soared to about 2,000 people from a few dozen, and more keep arriving. Families sleep on collapsed cardboard boxes at night, affixing sheets to fences to create shade during the day. Able-bodied men are asking for bus money to reach Houston, Denver and Orlando, where they said jobs await; little children roam the alleyways scavenging for food and begging for change.

“It’s a real crisis,” said Father Rafael Garcia, surveying the crowd sprawling in every direction one day last week. “If this is now, what is it going to look like after May 11? How is this going to unfold?”

That question is at the heart of a monumental challenge with a grim history. When the pandemic-inspired restrictions end, border officials will resume an immigration system that has largely failed for decades, but with the added pressure of three years of pent-up demand. About 35,000 migrants are amassed in Ciudad Juárez, another 15,000 in Tijuana and thousands more elsewhere on the Mexican side of the 2,000-mile-long border.

White House officials said they have worked for months to prepare for a likely surge. They have built temporary facilities to house thousands more migrants, hired contractors and cut processing time for people in custody. They have also taken steps to encourage a more orderly flow of migration.

A tough new rule that disqualifies asylum seekers who did not seek protection first in another country will go into effect on Thursday. At the same time, the administration is working with the United Nations and other countries to open processing centers in Colombia and Guatemala to encourage migrants to apply for refuge in the United States or other countries without trekking to the border. Recently, programs were added for migrants from a handful of other countries.

The president last week ordered 1,500 troops to assist at the border. But even so, officials are expecting a crush of people in the days ahead. Mr. Biden is up against global shifts in migration patterns, and economic forces and social unrest that are relentlessly driving people north. And inside the United States, the debate over how to fix the nation’s broken immigration system remains polarized and overheated, posing serious political risk for everyone involved as the 2024 election season begins.

No one is certain what will happen after Thursday. The federal government is expecting as many as 13,000 migrants each day immediately after the measure expires, up from about 6,000 on a typical day. But asked what is likely to happen, one official posted along the border told reporters, “I have no idea” and said of a possible surge: “I think it’s already here.”

Even while Title 42 has been in place along both the southern and northern borders of the United States, the number of people unlawfully entering the country has climbed precipitously and their profile has changed: More people from far-flung nations in economic distress or political turmoil, such as Venezuela, China, India and Russia, have been braving an arduous journey to reach the doorstep of America.

The impact of the increase in migrant crossings — more than 3 million in the first 18 months of the Biden administration and the most in decades — has reached beyond the border. Mayors in New York, Washington D.C., and elsewhere have said the influx has strained their resources, a situation made worse by Republican governors in Florida, Texas and Arizona who have bused migrants to those cities.

While migrants in droves have crossed in recent days, uncertain about their chances in the post Title-42 border regime or goaded by smugglers, even more are expected to seek entry after the measure is lifted, aware that they will not immediately be returned to Mexico if they turn themselves in, or betting that overworked border agents will not catch them if they run.

Those who are captured will enter a border processing system that is already crowded in many places. In the Rio Grande Valley, where the Border Patrol has a capacity for 4,600 migrants, officials reported having 6,000 in custody as of May 4, about two-thirds of them from Venezuela. A college baseball field in Brownsville, Texas, has been turned into a makeshift processing center.

Republicans are poised to use the scenes to bolster their political attacks on Mr. Biden and Democrats, accusing them of failing to secure the border. This week, House Republicans are poised to vote on a bill to revive aggressive Trump-era immigration policies that Democrats have long denounced as cruel. The Republicans are also moving toward impeachment charges against the Homeland Security secretary, Alejandro Mayorkas, as a way of dramatizing their accusations.

Last month, Representative Mark E. Green of Tennessee, the Republican chairman of the House Homeland Security Committee, told donors to “get the popcorn” for hearings aimed at exposing Mr. Mayorkas’s “dereliction of duty and his intentional destruction of our country through the open southern border.”

“It’s going to be fun,” Mr. Green told the room.

But for Mr. Biden, some of the fiercest criticism is coming from allies on the left, who say they are deeply disappointed in the measures the administration has adopted to limit the number of migrants admitted. The new rule requiring migrants to apply for asylum in the country they travel through on their way to the United States, they say, would illegally deny many even the chance to apply for refuge in America. The administration argues that more migrants now can apply legally, without risking a dangerous passage to the border.

Lee Gelernt, a lawyer for the A.C.L.U., said his organization will go to court immediately to block the new rules. Senator Robert Menendez, a Democrat from New Jersey, said aggressive alternatives do not address the broader forces causing people to migrate.

“The administration has gone down the rabbit hole that enforcement is the only way to deal with this challenge, and the problem with that is that it won’t solve the problem,” he said.

Eleanor Acer, the director of the refugee protection program at Human Rights First, said she was relieved that the Trump-era pandemic restrictions at the border were ending. But she said the new asylum rules were “illegal, immoral and totally counterproductive.”

Once the expulsion measure expires, some migrants will face prolonged detention, formal deportation and a five-year ban on entry into the United States. But making those determinations requires authorities to process migrants one by one, a cumbersome task that involves keeping large numbers of people in custody for days, in facilities that already are overwhelmed.

Last week there were days when more than 20,000 migrants were in U.S. custody, double the capacity. In El Paso, some 5,000 migrants were being held in processing facilities designed for fewer than half as many.

“We are getting prepared now for the unknown. The unknown is how many people will come here,” Oscar Leeser, the mayor of El Paso, told reporters on Thursday.

“Federal immigration laws are broken, and they didn’t break during this administration or the last administration,” he added. “We have to figure out where we are heading. There is no light at end of the tunnel.”

El Paso County has opened a large center where each day, 1,200 migrants released from U.S. custody can get help arranging onward travel. Nonprofit shelters are already full; the city is preparing to open two vacant schools, and it could also set up cots in the civic center.

But many of those who work on the border said no amount of preparation would suffice.

“We have been holding this wave off, and this wave is going to come crashing,” said Ruben Garcia, director of Annunciation House, a large shelter that is at capacity. “How long will it last? Clearly until many people come across from the buildup in Mexico. But many more are likely on their way.”

On a recent day, International Rescue Committee staffers advised migrants gathered for free lunch at the cathedral in Ciudad Juárez to use a mobile application to make an appointment at a U.S. port of entry, rather than risk their lives by crossing the Rio Grande or climbing over the wall.

But the app, introduced by the Biden administration in February to bring some order to the border, thus far has offered an extremely limited number of appointments and has been plagued by technical glitches.

Frustration with the app coupled with fear of being stranded in a violent Mexican border city, where migrants have been targeted for extortion and 40 of them died in a blaze at a detention facility last month, has pushed droves to cross the border in recent days at great risk.

In El Paso, many of those staying on the sidewalk outside Sacred Heart church said they had entered through gaps in the concertina wire that rims the riverbank, scaled the 30-foot-tall steel border wall and then evaded U.S. agents under the cover of darkness. They displayed arms with gashes and swollen ankles to prove it.

Because they had not turned themselves in and been processed by U.S. authorities, they were not eligible to stay in most shelters or to receive assistance from city or county facilities.

“The app is a joke; it’s a lie,” said William, 30, who said he had tried to use it again and again. So he decided to turn himself in, only to be expelled three times under Title 42. That morning, at 2:30 a.m., he had made it to El Paso undetected.

Like him, the vast majority by the church were Venezuelans. With little or no money, many said they hoped that somehow they would get help with transportation to places where they planned to make a fresh start.

“We don’t want anything from the American government,” said Daniel, 28, who like others asked that his last name be withheld because he had slipped into the country without being processed. “We just want to work.”

Eileen Sullivan contributed reporting from Washington.