TAPACHULA, Mexico—At midnight, the immigrants outside the gate of the local office of the Mexican Commission for Refugee Assistance know that only the first arrivals will get past the security guard in the morning. They prepare to buy gum, cigarettes, or breakfast pupusas—a traditional Salvadoran stuffed dough—from those who have made a business out of serving those waiting. Once they register, they will have weeks before the first interview. In the interim, some bring their children to sleep in the central park, while others make their way to local shelters.

The experience of these migrants is now at the center of a debate in Washington. In recent months, the U.S. administration led by President Donald Trump has spoken of officially designating Mexico a “safe third country” for asylum-seekers, giving it a role akin to that of Canada. The terminology surfaced in Secretary of Homeland Security Kirstjen Nielsen’s statements on the refugee caravan in April, in Mexico-U.S. negotiations in May, and in the Securing America’s Future Act voted down in the House in June.

The debate isn’t merely semantic. A change in Mexico’s status would, for instance, permit the United States to turn away many of the hundreds of thousands of people who submitted asylum applications in the United States last year, requiring those who arrived at the southern border to first submit applications in Mexico instead. It’s a proposal that some U.S. policymakers say makes sense because, over the past five years, a growing number of migrants have started to apply for refugee status in Mexico.

Claims that Mexico is a safe country by any conventional measure are dubious: Crime statistics show that 2017 was Mexico’s deadliest year on record, and Mexicans themselves still rank among the most common asylum applicants in the United States. (President-elect Andrés Manuel López Obrador was voted in, in part, on the promise of reducing migration to the United States by improving conditions for Mexicans at home.)

What has received less attention, however, is whether Mexico, despite its emerging status as a destination for other migrants, is truly capable of receiving them. Once a country of transit, Mexico is already buckling under the demands of its new reality. Although its government had once styled itself as a progressive defender of refugees, some immigrants are discovering that the country isn’t nearly as welcoming to its neighbors in need as its rhetoric suggests.

“It’s not that Mexico has decided to take more people,” said Irazú Gomez, a coordinator with the migrant defense organization Sin Fronteras. “People are arriving regardless, even if there is no political will.” The problem, she said, is that last year, “the system collapsed.”

If Mexico has a reputation for taking in exiles, that’s because in the 20th century the country famously accepted everyone from Lebanese traders, such as the family of billionaire Carlos Slim, to Cuban revolutionaries, such as the young militants who joined Fidel Castro after his release from prison. Specific presidents also sought to portray their country as magnanimous—though in practice, generosity was reserved for those who were deemed politically convenient, according to Javier Urbano Reyes, a professor of international studies at the Universidad Iberoamericana in Mexico City.

Lázaro Cárdenas, who served as president from 1934 to 1940, was known for bringing in Spanish exiles who fled from Francisco Franco’s dictatorship in Spain. His ambassador in France granted visas to people escaping from Nazi Germany. Luis Echeverría, who was president from 1970 to 1976, was in power when the widow of Chilean President Salvador Allende came to Mexico; he saw the early wave of migrants after the fall of the socialist governments in Chile and Argentina.

These historical cases, however, were exceptions to the rule. “Mexican migration policy has traditionally focused on containment along the border,” Urbano Reyes said. The country did not develop a consistent protocol for refugees, and for all its self-described grandeurs, the number of people it received remained modest; the Spaniards who sailed in on ships with names like Ipanema and Orinoco were received graciously in hotels on the coast but are estimated to have numbered only 25,000.

It was not until mass migration during the Guatemalan Civil War that the uglier side of Mexican immigration policy began to publicly emerge. During the 1980s, an estimated 50,000 migrants settled in camps in the state of Chiapas. At first, they returned to Guatemala in daylight and then retreated to Mexico at night, at times having to fend off invasions from the Guatemalan military. But Mexico was at times two-faced, known to have handed over alleged guerillas to the Guatemalan authorities.

It was in the face of this wave that Mexico created the Mexican Commission for Refugee Assistance, abbreviated in Spanish as COMAR, which eventually helped the government send many of the Guatemalans to live in isolated border territories in the states of Campeche and Quintana Roo. But according to María Cristina García, the author of Seeking Refuge, the office was soon hindered. It was placed under the Interior Department “theoretically to better coordinate assistance to the refugees, but also to control any dissident voices that challenged official government policy.”

Mexico thus failed to establish a refugee system that could respond to future crises, such as the civil war that displaced Salvadorans in the 1980s or the natural disaster that pushed out Hondurans in the 1990s. Its response to these problems was ultimately ad hoc: It harbored more than half a million Salvadorans but forced the majority to remain undocumented. For years, COMAR denied the Guatemalans visas that would allow them to establish themselves beyond the encampments and then encouraged their return to their original homes after the war.

When it came to migration policy, Mexico was instead focused on the rate at which its own people were bleeding out of the country. In the 1990s, the population of Mexican immigrants living in the United States grew by 5 million. “Mexico’s concern was how to attend to the Mexican immigrant population in the United States,” said Axel García Carballar, a former COMAR official. Aiding refugees, on the other hand, “has never been a national priority.”

In the early part of this century, after Mexico belatedly signed the 1951 Refugee Convention, which is the basis for international refugee protections, the United Nations turned over official responsibility for adjudicating refugee cases to the country. García Carballar said that the office came into its new role in the uproar immediately after Sept. 11, 2001, and it would struggle to fulfill its responsibilities in the years that followed.

Last year, more than 14,000 people applied for asylum in Mexico. That represents a drop in the broader ocean of migrants in Mexico, many of whom are looking to head farther north. But it’s a major increase from only five years ago, when just over a thousand people applied—the result, perhaps in part, of Mexican officials’ increased security measures and the Trump administration’s fiery rhetoric. Both have made some migrants living in Mexico illegally reconsider continuing north.

The people who end up staying are often those with fewer established family ties in the United States or those who have a network of earlier immigrants in Mexico to support them, according to Carlos Cotera, the coordinator in Tapachula for the Jesuit Refugee Service. Those from nearby countries stand in immigration lines next to Venezuelans running from economic collapse, Cubans who faced the end of the United States’ “wet foot, dry foot” policy, Haitians who had previously settled in Brazil, and Cameroonians fleeing conflict between their country’s army and rebel groups.

They are all obliged to have patience with a bureaucratic system that has developed at a snail’s pace. García Carballar remembered being one of only three interviewers in the office when the COMAR started processing applications. For years afterward, refugee applications were “treated like an administrative proceeding, the same as for tourists,” he said. It took another 10 years, until 2011, to develop a national law that granted immigrant rights such as medical care and education, though the Mexican government never fully followed through on all its promises.

Today, limited staff still sometimes leaves applicants in limbo. COMAR’s delegations exist only in the capital, Mexico City, and in two southern cities: Acayucan, one of the more violent cities in the cartel-controlled state of Veracruz, and Tapachula, in the lush border state of Chiapas. Officials also conduct interviews in the city of Tenosique, a more frequent crossing point for Hondurans. After immigrants have a preliminary interview, they are still obliged to wait in line once a week at the same office to sign in, attesting that they have remained in the city and wish to continue proceedings, the resolution of which will determine whether they will be granted the equivalent of a U.S. green card. (In the interim, those who voluntarily applied before being detained by Mexican authorities are supposed to eventually be given a temporary humanitarian permit that allows them to legally work.)

According to Mexican law, proceedings are supposed to take three months, an exemplary speed that would be unthinkable in the United States, where cases go unresolved for years. Unfortunately, it turns out to be equally unthinkable in Mexico. COMAR’s staff has struggled with its growing stack of applications. Five years ago, its budget hovered at $1.2 million dollars; last year, it inched up to $1.3 million. When an earthquake impacted their offices last September, COMAR’s staff continued to take new cases, but they indefinitely suspended the timeline for all open proceedings, leaving half of the year’s cases unresolved.

“We had cases that had not been resolved in five months, so the earthquake was just a pretext,” said Alejandra Macías Delgadillo, the director-general of Asylum Access Mexico. “If we suppose that the COMAR has 30 people, and you divide 7,000 cases between those 30 people, do you really think you can do an in-depth study of each case?”

The buckling of Mexico’s immigration system has directly affected migrants, including a 31-year old Venezuelan graphic designer who preferred to remain anonymous because his asylum application is still pending. After leaving his native country in December 2015 because his pay fell to less than 50 cents a day and he was unable to afford basic medicines, he chose to file for asylum from Monterrey, a city on Mexico’s northern border, where a friend of his already lived. But because the entirety of northern Mexico lacks a refugee office, his interview with COMAR was perpetually delayed.

As a result, he was never granted an interview and never received the identification number that would authorize him to become formally employed, obliging him to work for lower wages on the black market. When he traveled to Mexico City in March 2018 to see whether he could schedule an interview in person, he was detained on the bus back for not having documents.

“It’s a test to try to make you not stay in Mexico,” he said, explaining how his passport had been confiscated and he was held until it was established he had an open case. “For 18 days, I was in the migration station, and it was a deplorable situation. It was literally a jail.”

The legal aid organizations that work with Mexico’s asylum-seekers have often found themselves baffled by the disarray that COMAR is in. Cotera, of the Jesuit Refugee Service, had a case of a 32-year-old Somali man who, when he was denied asylum, was told by Mexican authorities he should have resettled in another part of El Salvador; it was a case of erroneously copying and pasting the answer that had been given to another person.

Immigrants to Mexico sometimes give up on staying in dusty towns upon the border, where there is almost no decent work. Those with temporary humanitarian permits can get on a series of buses without being detained by immigration agents, though they will still have to hope to avoid criminal groups or corrupt police who could kidnap them, assault them, or rob them blind. If they succeed, they can try their luck in the United States.

Like many Mexican policymakers, Ardelio Vargas Fosado, who served as the director of Mexico’s National Institute of Migration from 2013 to early 2018, assumes that migrants simply don’t want to stay in Mexico. That is why Mexico sends back the vast majority of the foreigners it detains—in 2016, officials stopped nearly 190,000 people, often by monitoring the highways and train routes north.

“Why don’t people resort to refuge in Mexico? Because they did not come to stay in Mexico,” Vargas Fosado said. “They ask me, ‘Is this going to help me get to the United States?’ I say, ‘Of course not. Refugee status is so that you stay here under the protection of the Mexican government and start a new life in Mexico.’”

Among would-be refugees in Mexico, the denial rate last year was 37 percent, by far better than the 62 percent in the United States. But those who leave the country before receiving a decision may nevertheless be making a strategic decision, according to Leonila Romero González, a coordinator for the Scalabrinian Mission for Migrants and Refugees shelter in Mexico City. “It’s expensive for them to stay here, so they think about crossing and then sending money back [to family members],” she said.

Others find themselves driven away by suspicions among Mexicans about immigrants. Central Americans are sometimes assumed to be criminals, which forces them into lower-rent and often more dangerous neighborhoods on the periphery of cities, thus reinforcing the stereotypes. In 2017, the local newspaper Diario Del Sur published a photograph of tattooed men with the headline “COMAR: Refuge of Gang Members in Chiapas.”

López Obrador has indicated that, after he takes office in December, he would like to close the gap between Mexico’s generous legal provisions for migrants and the strained reality. He has already proposed Alejandro Solalinde, a celebrated priest who created one of the most prominent migrant shelters in Oaxaca, as the head of the National Human Rights Commission. In a letter he sent to Trump on July 12, he also suggested that the United States, Mexico, and Central America all invest in a regional plan to reduce migration: 75 percent of the money would be to increase employment and diminish poverty, and the remainder would be for border security.

“Every government, from Panama to the Rio Grande, will work to make the migration of its citizens economically unnecessary and will care for its borders to avoid the illegal transit of goods, arms, and drugs, which we see as the most humane and effective way to guarantee peace, tranquility, and security for our people and nations,” he wrote.

López Obrador has also endorsed the Mexican government’s announced commitment, prior to the election earlier this month, that it planned to increase COMAR’s staff by 84 percent and to start granting all asylum-seekers an identification number so they are not obliged to work on the black market while their applications are being processed. But the president’s ambitious plans have not spared him controversy. His pick for chief of public security, Alfonso Durazo, said in an interview with Bloomberg that the new administration planned to create its own border police force. He later clarified, in response to swift backlash, that it would be exclusively for tourist regions—nothing to do with immigration enforcement.

Ultimately, the president-elect’s priority will be to improve conditions for his own citizens so that they are not forced to migrate and instead remain at home. That has limited relevance for immigrants who are caught in Mexico’s bureaucratic dysfunction as they consider where to start their lives anew.

“When I started the process, they told me it would only be three months,” said Anderson Hernández Miranda, 18, a migrant from Honduras who dealt with COMAR’s stalled bureaucracy over the course of his first year in the country, while sleeping in a church-run shelter. “I almost left, but the priest stopped me and told me I should think about whether my life is important to me.” It was an acknowledgment that the Mexican government’s provisions for migrants aren’t good enough—but they are often still, sadly, better than any alternative.