GUATEMALA CITY — Vice President Pence demanded more from Central American leaders on Thursday during a meeting about the growing number of migrants being detained at the U.S. border, a situation that has flared into a political and humanitarian crisis for the Trump administration.

Pence’s visit came at the conclusion of a swing through Latin America during which he has warned migrants not to risk their lives by trying to enter the United States illegally. He met Thursday evening with the leaders of Honduras, El Salvador and Guatemala, the home countries of the majority of the migrants detained on the southwest U.S. border.

Speaking at a news conference following a roundtable meeting that included Homeland Security Secretary Kirstjen Nielsen, Pence said, “I told the presidents I met here that this exodus has to end. It is a threat to the security of the United States, as we respect your sovereignty and your borders, we demand you respect ours.”

A technical error allowed journalists to listen in on part of the meeting where Pence called for the use of technology in border areas to track human traffickers. He asked Honduran President Juan Orlando Hernández to select a “stable” and “independent” attorney general and complained that the United States was “seeing real threats that we have to secure our borders from.”

Nielsen was heard saying, “We know that family separation is a difficult issue, but that would not be a problem if [migrants] seek asylum correctly.”

A follow-up meeting in Miami next week to discuss the Alliance for Prosperity, an Obama-era plan to promote economic growth and social equality in Honduras, Guatemala and El Salvador, was also considered.

Pence called on the three Northern Triangle presidents to be more active and had a message for people considering the journey north. “Our nations need your countries to do more [on the issue of migration],” he said. If you want to come to the United States come, but come legally. Don’t risk your lives or your kids’ lives, don’t leave them in the hands of human traffickers or drug traffickers.”

In reply, Hernández said, “The trafficking of arms, people and narco-trafficking are the problems that we must strike at the root of. To put into context, we face a monster of several heads and faces and one of those faces is drug trafficking.”

Some Central American leaders have been criticized domestically for their lukewarm initial reactions to the border crisis as migrant parents have been separated from their children under the Trump administration’s “zero-tolerance” policy. While Trump has since suspended the separations, more than 2,000 children are still being kept in shelters as their parents frantically try to find them.

Guatemala’s president, Jimmy Morales, fired his spokesman for initially saying his government agreed with the zero-tolerance policy, which seeks criminal prosecution of people illegally crossing the border. El Salvador’s deputy foreign minister, Liduvina Magarin, has publicly called on citizens not to travel illegally across the U.S. border, and complained that conditions in shelters were “totally inadequate.”

On Tuesday, during a stop in Brazil on his tour, Pence told migrants in the nation to “build their lives in their home countries.”

At least 465 of the more than 2,500 children who were separated from their parents at the border are from Guatemala. However, this figure is not believed to include those in Border Patrol custody, which could add many more to the total.

Fernando Carrera, a former Guatemalan foreign minister, said that merely warning migrants not to travel illegally to the United States would have little effect.

“You have to increase resources massively to reduce poverty and violence” that push people to leave their homes, he said. But he added that many children seek to reach the United States because they have family members there.

Morales is hoping the Trump administration will provide temporary legal status for Guatemalans who are living in the United States, following the eruption earlier this month of the Fuego Volcano, which left at least 109 people dead and hundreds missing. However, the White House has recently ended similar programs that had been established years ago for Salvadorans and Hondurans, making it unlikely a new one will be approved.

The U.S. government has provided billions of dollars in aid to the three Central American countries over the past decade. But they suffer from extreme violence, poverty and political instability.

In the past couple of months, violence has grown in Guatemala, with signs emerging that gangs have even infiltrated Guatemala’s military. That may help to explain a spike in migration. Other experts point to traffickers who tell their clients they are more likely to be allowed to stay in the United States if they arrive with children.

There has been a 71 percent year-on-year increase in deportations from the United States to Guatemala in the first five months of 2018.

“Many small communities from rural areas in Guatemala have already migrated to the U.S. and that will always lead to the desire of many people to travel and reunite no matter what the conditions are in the country of origin,” said Pedro Pablo Solares, who works for Puente Norte, a nonprofit group that assists Guatemalan migrants.