U.S. and Mexican officials have agreed on a plan to handle the approaching migrant caravan making their way up from Central America, a senior administration official told Fox News on Thursday.

Under the deal, which was developed over the course of several months, Mexico requested that the United Nations High Commissioner for Refugees (UNHCR) establish shelters along its southern border with Central America, the official said.

Mexican Ambassador to the U.S. Geronimo Gutierrez elaborated on the request, during an interview on Fox News’ “Special Report.”

“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,” Gutierrez 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.”

Gutierrez also retweeted a news release Thursday detailing Mexico’s request to the UNHCR.

MIGRANT CARAVAN BREAKAWAY GROUP REPORTEDLY REACHES BORDER WITH MEXICO AS SHOWDOWN LOOMS

“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,” Secretary of State Mike Pompeo said in a statement. “The United States stands ready to assist the Government of Mexico and UNHCR in this effort.”

If an individual manages to evade the new system and travels through Mexico to eventually cross the border into the U.S., Mexico will now allow those persons to be returned to Mexico, the official told Fox News. Currently, the U.S. has had to house those people until their cases could be adjudicated before being removed to their country of origin.

At the established shelters, U.N. officials will vet the refugees to decide which ones have legitimate claims for refugee status, the official told Fox News.

If a person or persons is determined to have a legitimate claim, they will undergo a U.N. process of being placed in a host country, which could ultimately be the U.S. or any other country that has an agreement with the UNHCR, the official said.

TRUMP THREATENS TO CALL US MILITARY TO CLOSE SOUTHERN BORDER AS 4,000-STRONG MIGRANT CARAVAN PUSHES NORTH

All those discovered without a legitimate claim will be sent home, the official said. And those who don’t have correct documentation will be turned away at the Mexico border.

The plan was agreed on by members of Mexico President Enrique Pena Nieto’s government, however President-elect Andres Manuel Lopez Obrador’s incoming administration has vowed not to criticize the plan, the official said. After they take office, they have agreed to work together with the U.S. to attempt to make the plan endure long-term.

The caravan, which started in Honduras last week, is currently bound for the U.S. As of Thursday, a migrant shelter located on the Guatemalan side of the border with Mexico said that hundreds of the caravan’s migrants had reached the area, according to The Associated Press.

The caravan drew the ire of President Trump earlier Thursday on Twitter, who threatened military force and a closure of the U.S. southern border. He also slammed leaders in Guatemala, Honduras and El Salvador for “doing little to stop this large flow of people” and requested that Mexico “stop this onslaught.”

Fox News’ Greg Norman, Nicholas Kalman and The Associated Press contributed to this report.