The Department of Homeland Security announced new measures Thursday requiring asylum seekers at the border to return to Mexico and wait while their claims are processed, possibly for months or years, describing the plan as one of the most significant changes to immigration policy in decades.

Homeland Security Secretary Kirstjen Nielsen outlined the new measures during a contentious oversight hearing with members of the House Judiciary Committee, telling lawmakers that the administration is preparing to implement the policy in coming days. They will be introduced at select locations before expanding across the entire southern U.S. border, officials said.

Separately, Mexico’s new leftist government announced Thursday that it will allow the United States to send asylum seekers who cross illegally back to its territory and provide them with work visas and humanitarian assistance while they wait.

The policy is likely to face legal challenges, and federal courts have repeatedly blocked the Trump administration’s efforts to tighten border controls via executive action. Nonetheless, the deal amounts to a significant diplomatic win for the administration, which has engaged in delicate talks to cajole Mexico to become an immigration antechamber for Central Americans seeking U.S. asylum.

The new policy will apply to migrants who request humanitarian protections at U.S. border crossings, as well as those who enter the country illegally, DHS officials said. Citing emergency powers allowed under the Immigration and Nationality Act, Nielsen said the measures were needed to “bring under control” a surge of unmerited asylum claims by Central Americans that led to a backlog in U.S. immigration courts of more than 750,000 cases.

“Aliens trying to game the system to get into our country illegally will no longer be able to disappear into the United States, where many skip their court dates,” Nielsen said in a statement. “Instead, they will wait for an immigration court decision while they are in Mexico.” 

“Catch and release will be replaced with ‘catch and return’,” she said, using President Trump’s disparaging term for current procedures, which typically allow those whose fears are determined to be credible to be released from custody while they await a distant court date. DHS officials liken that arrangement to a “loophole” that is bringing record numbers of migrant families to the border and overwhelming U.S. agents.

Under the new policy, Nielsen said, “They will have to wait for approval to come into the United States. If they are granted asylum by a U.S. judge, they will be welcomed into America. If they are not, they will be removed to their home countries.”

Nielsen had several heated exchanges with Democratic lawmakers during Thursday’s hearing, while Republicans jumped to her defense, praised Trump’s plan for a border wall and welcomed the new asylum rules.

For Nielsen, Thursday’s announcement helped deflect some of the attention on the case of 7-year-old Jakelin Caal, who died Dec. 8 after she and her father were taken into Border Patrol custody in New Mexico. During the hearing, Nielsen acknowledged that she was informed of the child’s death by her staff that same day, though neither she nor other DHS officials reported the incident to Congress and the public.

DHS officials said they will implement the new border policy in the coming days, and migrants who established a fear of harm if they stay in Mexico will be allowed to enter the United States. But U.S. asylum officers, including those who began receiving implementation guidance weeks ago, said they were not informed that the measures were imminent until Thursday’s announcement.

Homeland Security officials have said they will be able to process at least twice as many asylum claims by requiring applicants to wait in Mexico, in addition to saving money on detention and enforcement.

Homeland Security officials called the policy a unilateral decision, and Mexican diplomats characterized the measures Thursday as steps they have acceded to begrudgingly. Behind the scenes, though, the two countries have engaged in sensitive negotiations for weeks, as Trump fumed about migrant caravans and threatened to close the border, spooking Mexican officials. 

Top Mexican officials from the recently inaugurated government of President Andrés Manuel López Obrador have said they would acquiesce to the policy as part of a broader development and aid package aimed at creating jobs in Central America and reducing the need to emigrate. 

Mexican officials also said they were concerned about additional caravans passing through their territory and willing to make the gesture to Trump with hopes of securing his support for their preferred approach: a “Marshall Plan” for Central America.

The rough outlines of the asylum overhaul were worked out with Mexico’s foreign minister, Marcelo Ebrard, and others by Nielsen, Secretary of State Mike Pompeo and a small team of aides who met at a Houston-area hotel last month, according to a Trump administration official familiar with the talks who spoke on the condition of anonymity to discuss the sensitive negotiations.

Mexican officials insisted the policy did not amount to an agreement, but was instead being imposed on them by the United States.

This was a unilateral measure by the U.S. Our response is according to our law and our commitment to a secure, orderly and legal migration,” said Roberto Velasco, a spokesman for Mexico’s Ministry of Foreign Affairs. “We’ve found some issues where we have a level of mutual understanding . . . and others on which our approaches differ.”

Velasco said the Mexican government was informed at 8 a.m. Thursday of U.S. plans to implement the policy. The government had not received prior notice that such an announcement would be made. The surprise announcement “didn’t sit well” with the Mexicans, said a second government official, speaking on the condition of anonymity to discuss diplomatic developments.

The main problem, he said, was the timing. The Mexican government didn’t want to signal that “we were ‘giving in’ to the Trump administration in the first months of the new administration.”

“At the end of the day, Nielsen and Trump decided to go ahead with it, notwithstanding the good climate that had been characterizing our initial dialogue” with the Trump administration, he said.

Mexican officials added that they would not be serving as an enforcement arm of the U.S. government and that migrants going through their asylum process would be able to work and travel around Mexico freely while awaiting their appointments in the United States. 

“We’re not going to have a detention center, nothing like that,” Alejandro Celorio, the deputy legal counsel at the Foreign Ministry, said at a news conference.

Officials also batted down suggestions that border cities would be overwhelmed, saying that migrants would receive work visas and could live anywhere in Mexico while awaiting their U.S. hearings.

“We don’t believe this will involve large groups, or flows that can’t be received with controls and with dignified conditions,” said Alejandro Alday, the ministry’s senior legal counsel. But he acknowledged Mexico had no idea how much it would have to spend to host the migrants.

“I have to wonder if Mexico knows what it’s signing up for,” said Adam Isacson, a border security analyst at the Washington Office on Latin America. “Wait times for asylum hearings are now routinely exceeding 1,200 days. That’s three years. Is Mexico really prepared to host hundreds of thousands of people for that long while they wait for overworked U.S. asylum judges to get to these people’s cases?”

Officials said that civil society groups — not the Mexican government — would work with the migrants to ensure they crossed the border in time to attend their hearings.

On Tuesday, the Mexican government announced that the United States will contribute $10.6 billion to programs in southern Mexico and Central America that ostensibly would help curb migration. 

But that funding mostly consists of money the United States already had allocated. Mexican officials denied any link between that statement and Thursday’s announcement.

In a statement, Mexico’s foreign ministry said Thursday that it “will authorize, for humanitarian reasons and temporarily, the entry of certain foreign persons from the United States who have entered the country through a port of entry or who have been apprehended between ports of entry, have been interviewed by the authorities of migratory control of that country, and have received a summons to appear before an immigration judge.”

They will be allowed “to our country so that they can wait here for the development of their immigration process in the United States,” the statement said.

“They will be entitled to equal treatment without any discrimination and with due respect to their human rights, as well as the opportunity to apply for a work permit so they can find paid jobs, which will allow them to meet their basic needs,” it continued.

It’s not immediately clear how Mexico will pay to provide humanitarian support for tens of thousands of asylum seekers. Mexico has slashed its budget for refugees in recent years, and López Obrador’s proposed budget for next year includes a 20 percent funding cut for its refugee agency. The new president has long spoken about the need to respect migrant rights, but many in Mexico saw his budget announcement as a sign of his priorities. 

In recent weeks, following the arrival of a large migrant caravan in Tijuana, Mexico’s lack of preparedness has become clear. When the caravan arrived, the government initially created a makeshift shelter in a sports complex. It was cramped, flood-prone and presented public health risks.

Last weekend, two Honduran teenagers who were part of the caravan were found murdered in Tijuana, a city suffering record levels of homicides. Mexican police said the two boys had left a shelter for migrant youths and were killed in an apparent robbery attempt. It’s unclear whether the boys had applied for asylum in the United States. 

Other parts of northern Mexico also present grave challenges for migrants. In the state of Tamaulipas, for instance, which borders southeastern Texas, migrants are regularly kidnapped and extorted, and there is limited space in shelters already inundated by deportees from the United States.

In Reynosa, kidnappings are so common that the city’s Casa del Migrante, run by a Catholic charity, has implemented a new rule: Migrants are not allowed to leave. “They leave to buy a sandwich and they disappear,” said Sister Edith Garrido, who has worked at the shelter for three years. 

Because asylum cases can drag on for months or years, it’s unclear how migrants would remain safe — with access to food and shelter — or how they would access legal services. It also remains unclear how Mexico will sell the deal to a domestic audience which has resisted the idea of embracing tens of thousands of Central American migrants. 

Sieff and Sheridan reported from Mexico City.