WASHINGTON — When Stephen Kelly arrived in Mexico City in 2004 to serve as the second in command at the U.S. Embassy, he found that no one from the Mexican army would agree to meet with him.
"It was definitely not career enhancing for a Mexican officer to be seen with American diplomats," he said.
Thirteen years later, however, U.S. and Mexican forces cooperate closely on a variety of issues: sharing sensitive intelligence, working together to fight drug trafficking and terrorism, training to combat organized crime and patrolling the shared border. American soldiers even have been allowed to carry their weapons into Mexico, something Kelly said "was unimaginable 15 years ago."
But that level of trust may fray, former officials and analysts say, as President Donald Trump portrays the United States' southern neighbor as a threat, with little seeming awareness of the complexity and sensitivity of the security relationship between the countries.
"At a minimum, Trump's team seems tone deaf, because they haven't had adequate experience engaging Mexico to understand the nature of the relationship," said David Shirk of the University of San Diego's Justice in Mexico initiative.
Shirk points out that the U.S. has been trying to ease Mexican suspicions around cooperating militarily for most of the last century. "That the U.S. would court Mexican military cooperation for decades only to turn around and suddenly treat them as an enemy and a threat really reverses the progress that has been made," he said. "Trust is a very, very difficult thing to build, and it's a very easy thing to destroy."
Trump's insistence that he will force Mexico to pay for a border wall led to the cancellation of a visit by President Enrique Pena Nieto last month. In a subsequent phone conversation between the leaders, leaked by unnamed sources, Trump threatened to send U.S. troops into Mexico to get rid of "bad hombres down there," saying the country's own military "is scared."
Even though the Mexican government denied the report and the White House said the comments were meant to be "lighthearted," they added to the growing tension between the U.S. and Mexico. Some of Trump's comments about Mexico on the campaign trail — painting the people as criminals, the government as an economic moocher, the military as weak — won't be forgotten easily.
"With the American rhetoric being so aggressive, it is already starting to affect the foundation of the security collaboration," said Raul Benitez Manaut, a security expert at Mexico's National Autonomous University. "Even though nothing has become law yet, it will be harder to work together now that the nationalist discourse from Trump has created a defensive reaction … with growing nationalism here in Mexico."
The partnership between the militaries took decades to build up.
"For a long time the U.S. military talked about the inefficiency and corruption of the Mexicans, and the Mexican side pointed to the imperialist attitude of the American forces," Benitez Manaut said. "But mutual trust was built up slowly, bit by bit, by a sense of shared security and shared responsibility."
Many U.S. defense officials spent their entire careers working on the relationship with their southern neighbor. Every year since the end of World War II, the U.S. Army has hosted seven Mexican army senior generals and their spouses on visits to military and civilian agencies in the United States in a bid to strengthen the partnership.
"Most Americans don't remember that we invaded Mexico at least three times, and forced it to give up nearly half of the territory they won in their independence from Spain," said Kelly, who served as deputy chief of mission at the U.S. Embassy in Mexico from 2004 to 2006. "Nowhere is that feeling of invasion, that Mexico has been robbed and violated, more strongly felt than in the Mexican army."
A turning point came when Mexican soldiers crossed the border for the first time in over a century in 2005, driving 45 military vehicles through Texas to aid New Orleans after Hurricane Katrina.
"Afterwards, things loosened up considerably," Kelly said. "Suddenly visiting U.S. generals could get appointments more easily, and the relationship with the army was noticeably better."
But Trump's threats and combative attitude have left Mexican officials "fumbling around trying to find the right response," he said, not wanting to undo the progress that has been made.
Mexico's military has struggled with its image in the wake of corruption scandals within its ranks, as well as the high-profile escape of drug lord Joaquin "El Chapo" Guzman. The drug kingpin repeatedly slipped through Mexican law enforcement's hands, including an escape from a maximum security prison in 2015 through a mile-long tunnel leading out from the drain of his shower, deeply embarrassing the Mexican military.
Despite setbacks, the defense relationship in recent years has paid off for both sides.
The recapture of El Chapo was carried out by Mexican marines who had been specially trained by American forces for years and have become elite partners of the United States in the drug war.
The Pentagon spent $60 million from 2010 to 2015 training Mexican forces, teaching more than 7,670 elite courses to 9,000 soldiers and marines, according to an analysis by the Mexican newspaper Milenio. The training focused on special tactics, anti-narcotics operations and anti-terrorism strategies, according to the report.
Some Mexican forces have been trained at the John F. Kennedy Special Warfare Center at Fort Bragg, N.C., which regularly trains U.S. forces including the Rangers and Green Berets. Eight top commanders of the Mexican marines were also sent to Fort Benning, Ga., to take a two-month combat course.
In what the then-head of the U.S. Northern Command, Navy Adm. William Gortney, called "a historical milestone in our security relationship with Mexico," Mexico took the "unprecedented" step in 2015 of reaching out to the Pentagon to go on a buying binge of military equipment. It bought more than $1.15 billion worth in a year, including ammunition, Humvees and 21 Black Hawk helicopters, in what Gortney said was "a 100-fold increase" from previous years.
In January, Mexico began to allow uniformed, armed U.S. border authorities to inspect U.S.-bound trucks entering the country on Mexican soil in Tijuana. Just a decade earlier a similar proposal had fallen through, with Mexico saying the public would never agree to Americans carrying weapons in their country.
Open communication between the countries' militaries is also necessary to prepare for a host of potential emergencies involving their shared border and airspace.
In one example, a training exercise last summer spanning the U.S. Northern Command, the North American Aerospace Defense Command, the Federal Aviation Administration, the Transportation Security Administration and their Mexican counterparts worked together on what to do if an illicit flight entered their airspace. The training involved flights by various aircraft, the dispatch of observers to different locations in Mexico and the U.S., and the careful coordination of a response that would not involve any military units crossing the border in either direction.
Despite corruption and other scandals within the Mexican army, U.S. forces who work with the Mexican military quickly get over "the concept that it is just a Third World military," said Evan Ellis, a professor at the U.S. Army War College who specializes in Latin America.
"For me, the untold story is the respect that has grown within U.S. forces and (U.S. Northern Command) for the professionalism and sacrifices of our Mexican counterparts," he said. "One of the greatest things I've seen is watching our officers develop a sense of respect for how they put their lives on the line in a very bloody conflict in their own urban areas."
Wall or no wall, the cooperation of Mexican authorities will continue to be crucial when it comes to sharing information. And with Central Americans making up the majority of immigrants entering the U.S. illegally through Mexico in recent years, working with Mexico on securing its southern border with Guatemala would go further to stem the problem Trump is worried about than a wall, analysts say.
"It's very alarming how quickly this could unravel, and that the seeds of goodwill we fostered under both Republican and Democratic administrations may quickly evaporate," Shirk said. "In uncertain times with very real security threats, it makes little sense to create enemies out of allies. Can we rely on an embittered Mexico to have our backs?"