PEÑITAS, Panama — A Guatemalan official thumbed through the soft soiled pages of a ragged Pakistani passport for a man who had just emerged from the jungle.

The disheveled migrant stared ahead as the nation’s interior minister and acting U.S. homeland security secretary Kevin McAleenan reviewed the visa stamps inside the worn document: Yemen, Djibouti, Turkey and Saudi Arabia.

The man had traveled all over a distant hemisphere but had found his way to a humanitarian camp on the edge of one of the most dangerous corridors in Latin America.

“We got to take a look at this cat,” McAleenan said as he watched an agent take fingerprints, retinal scans and other biometrics, destined for an information-sharing program that checks the data against U.S. and international criminal databases.

The relationship between the Panamanian and U.S. governments is one of enduring cooperation since the early days of the Panama Canal, but the explosion of migrants from outside Latin America traversing the isthmus to journey north to the United States has triggered a new conversation about border security. This group of migrants — known as extracontinentals — immigrate to South American countries to work and, after some time, continue north.

The 100 miles of dense tropical rainforest, marshland and treacherous rivers known as the Darien Gap has been a natural barrier to intercontinental migration for years because there is no road linking South America and North America. U.S. officials estimate that about a decade ago, fewer than 100 people per year attempted to travel through the remote wilderness, home to paramilitary guerrillas, traffickers and indigenous tribes. This year, more than 17,000 migrants, primarily from Haiti and Cuba — and from as far away as Nepal, Burkina Faso and Congo — have paid smugglers to lead them along foot paths next to swollen waterways or used WhatsApp to follow a trafficker’s directions. They face dangers from wildlife, criminals and disease.

Those who survive continue on their way to the United States, and some arrive with plans to harm the country, DHS officials said. Panama, in conjunction with U.S. authorities, has repatriated two people from the Middle East who came through the Darien this year and were on lists of potential terrorists or those with possible links to terrorism.

“There is shared concern about movements of extracontinentals, especially from outside the hemisphere, that could present security risks,” McAleenan said. “The goal was to engage partner governments that have that first opportunity, when someone is entering the hemisphere and who is clearly intending to migrate.”

McAleenan traveled last week to the 100-mile-long Panama-Colombia border as part of meetings with leaders from seven Central American countries and Colombia to discuss stronger security collaborations.

The acting secretary said he didn’t come to negotiate a specific agreement but the meetings are part of a broader DHS effort to help countries rework their asylum and immigration institutions. Together with its partners, DHS says it not only wants to stop lucrative trafficking networks but also prepare those governments to potentially take in U.S.-bound migrants who officials say are overwhelming the U.S. immigration system.

Under threat of U.S. tariffs, the Guatemalan president signed one such deal that could prevent thousands of Central Americans destined for the United States from reaching the border with Mexico. But the widely unpopular deal is on hold after Guatemala’s Constitutional Court ruled that any “safe third country” agreement would require legislative approval.

Interior Minister Enrique Degenhart said his government is waiting on clarification from the courts, but he is confident Guatemala has the means and right implementation plans to grant asylum to Honduran and Salvadoran migrants within their borders.

There is no such deal in the works for Panama, the Panamanian president said. During his trip, McAleenan talked to and toured the Peñitas humanitarian camp with Security Minister Rolando Mirones.

“What we need are regional solutions, not bilateral ones,” Mirones told reporters before the summit. “It’s not a problem that can be solved bilaterally.”

But there were other areas where bilateral negotiations are necessary, McAleenan said. U.S. law enforcement officials have deep ties in Panama, where local agents are embedded in the country’s sea and airports and help support local drug-trafficking investigations.

U.S. Customs and Border Protection bought the giant screening machines that take X-ray images of suspicious shipping containers at four of the country’s marine ports. And at the Panamanian border in the Darien, U.S. officials supplied Panama’s border security force, SENAFRONT, with the devices that capture fingerprints, photographs and iris scans to process the influx of migrants showing up at the Peñitas camp.

The migrants often arrive emaciated, sick and dangerously dehydrated after seven to 10 days of traveling the jungle, officials said. Humanitarian groups provide food, medical attention for maladies such as dysentery and dengue fever, and filtered water from a muddy river to quench their thirst.

Agents, meanwhile, register biometric information from 50 to 60 migrants a day into BITMAP, or the Biometric Identification Transnational Migration Alert Program, inside a guard shack. But the migrants can bypass the authorities at the camp to avoid detection.

The migrants come to recover, living in concrete block shelters and wooden shacks with tin rooftops that stand on stilts, the way the local indigenous communities build their homes, to evade wildlife and flooding, but the migrants are not in detention, security officials said.

Any given day, there are 300 to 500 migrants — including a small number of children — in the camp making phone calls to relatives and recuperating for the next leg of their journey. Panamanian border officials said they do not stop most migrants from continuing.

While McAleenan asked Panamanian border agents what more they needed to do their work, he noticed one agent manually inputting information from the Pakistani migrant’s passport into the biometric database. The Panamanian agent explained they had only two agents to do all the screening work for migrants in the camp each day.

He called for the local DHS attache to come over.

“Why don’t they have a passport scanner?” McAleenan leaned in and whispered. “Let’s get them one. We can do that.”