A deal emerged Thursday night between the United States and Mexico to avert an approaching crisis triggered by the second caravan in 2018 of migrants heading toward the United States.

Mexico’s ambassador to the United States, Gerónimo Gutiérrez, retweeted a news release announcing that Mexico has requested help from the U.N. High Commissioner for Refugees (UNHCR). UNHCR will provide help evaluating the asylum claims of the migrants before they cross into the U.S.

The deal comes just a few months before Mexican President Enrique Peña Nieto (pictured above right) leaves office. His successor is Andrés Manuel López Obrador, who has been cooperative in trade talks between the U.S. and Mexico.

Launched Saturday from Honduras, the caravan reportedly has grown to more than 4,000 people, including whole families and — in some cases — children traveling without their parents.

U.S. Secretary of State Mike Pompeo praised the Mexican government.

“We welcome the government of Mexico’s statement that they will seek cooperation with the United Nations High Commissioner for Refugees (UNHCR) to address immigration issues in the region, including the influx of people arriving in Mexico,” Pompeo said in a statement. “The United States stands ready to assist the Government of Mexico and UNHCR in this effort.”

Related: See What This Angel Mom Thinks of Nancy Pelosi Calling Border Wall a ‘Manhood Issue’ for Trump

Significantly, the deal also reportedly includes an agreement by Mexico to accept any non-Mexican who breaks away from the caravan and makes it into the U.S. This is important because, under long-standing practice, Mexico accepts only Mexican citizens deported from this country.

This complicates efforts to deport Central Americans who travel through Mexico in the United States because American officials must arrange to fly apprehended illegal immigrants to their home countries.

Gutiérrez made the rounds on cable news programs Thursday night explaining his country’s position.

Who do you think would win the Presidency?

By completing the poll, you agree to receive emails from LifeZette, occasional offers from our partners and that you've read and agree to our privacy policy and legal statement.

“The Mexican government does not condone irregular immigration … At the same time, we cannot close our eyes to the humanitarian situation that has been presented,” he told CNN’s Chris Cuomo.

Gutiérrez told Fox News that his country would accept those with genuine asylum claims.

Related: Trump to Send Troops, Close Border if Mexico Won’t Stop Migrant March

“Just today, the Mexican government, and this is a very important step, requested the intervention of the U.N., the Office of the High Commissioner on Refugees, to help Mexico review any asylum claims from the members of the caravan,” he said.

“That will allow us to have a process by which, in our border, we will make sure that of serving human rights, respecting international law, if there are legitimate claims to refugee, those can be processed in a very clear way.”

U.N. officials will conduct the refugee evaluations at established centers. People determined to have legitimate claims will be placed in host countries.

Those without legitimate claims will be sent to their home countries, Gutiérrez said.