A Mexican federal district judge in Tijuana on Friday ordered the immediate release of a U.S. Marine veteran being held in Baja California on federal weapons charges.

Andrew Tahmooressi, who was on trial for crossing the border with ammunition and three loaded weapons on March 31, returned to the United States Friday night and flew to his family’s home in Florida.

The decision by the Mexican Attorney General’s Office to cease its prosecution of Tahmooressi brings to a close a high-profile case that has resounded far beyond the border.

In the United States, it prompted calls for Tahmooressi’s release from politicians, veterans groups and conservative talk show hosts. But for months there had been an impasse, as Mexican federal prosecutors insisted that the case be resolved through the courts — not through diplomatic or political pressure.

Tahmooressi, 25, claims he drove into Tijuana by mistake on a Monday night after taking a wrong turn near the Mexican border in San Ysidro. He had recently moved to San Diego from Florida, and says that he was driving out of a parking lot, intending to head north. But instead he drove into the El Chaparral Port of Entry, where Mexican customs inspectors examined his pickup truck and found more 400 rounds of ammunition and three loaded firearms: a .45-caliber pistol, a 12-gauge shotgun and a 5.56 mm assault rifle.

His release was ordered by Judge Victor Octavio Luna Escobedo of the Sixth Federal District Court in Tijuana. Had Tahmooressi been convicted, he would have faced seven to 21 years behind bars.

Luna Escobedo declined to comment. A statement from Mexico’s Federal Judicial Council said the judge ordered dismissal of the case after federal prosecutors withdrew their accusation in closing arguments. The judge ordered Tahmooressi’s “immediate and absolute liberty.”

According to one Mexican official familiar with the case, the grounds for the dismissal were that he is unfit to stand trial because he suffers from post-traumatic stress disorder.

Alejandro Tamayo / U-T San Diego

Former U.S. Marine Andrew Tahmooressi is released from Mexican custody Friday. Here Tahmooressi gets out of a pickup truck at the border to go through U.S. Customs into the United States. U-T San Diego photo by Alejandro Tamayo

Former U.S. Marine Andrew Tahmooressi is released from Mexican custody Friday. Here Tahmooressi gets out of a pickup truck at the border to go through U.S. Customs into the United States. U-T San Diego photo by Alejandro Tamayo (Alejandro Tamayo / U-T San Diego)

On Friday night, Tahmooressi was driven from El Hongo State Penitentiary east of Tecate to the San Ysidro Port of Entry. He walked across the border at about 9 p.m., got into a vehicle and was taken to Brown Field.

He boarded a private jet provided by a foundation run by former New Mexico Gov. Bill Richardson for the flight to Florida. Richardson, who met with Tahmooressi in prison last week, was also on the plane, as were the former Marine's mother, Jill Tahmooressi; media personality Montel Williams; and his former commanding officer in Afghanistan, Sgt. Robert Buchanan.

Royce and U.S. Rep. Matt Salmon, R-Ariz., were at Brown Field to see Tahmooressi off.

The weapons and ammunition confiscated from Andrew's Tahmooressi's vehicle.

The weapons and ammunition confiscated from Andrew's Tahmooressi's vehicle.

His family released a statement expressing its relief for his return.

“He is back on American soil and will shortly resume treatment for both his pre-existing Combat Related PTSD and the residual effects of months of incarceration – which has taken a toll on him far worse than his two tours in Afghanistan,” it said.

Even though the U.S. State Department reports that dozens of U.S. citizens are arrested each month for violating Mexico’s gun laws, few if any cases have received such wide attention.

Tahmooressi’s situation initially elicited little public sympathy in Mexico, where gun laws are far more restrictive than in the United States. A headline last May in the Tijuana newsweekly Zeta read: “He did not enter Mexico in error.” But his detention did strike a nerve with some sectors in the United States intent on seeing him released.

Portraying Tahmooressi as a U.S. war hero unjustly detained in a foreign country, they invoked his military service — two tours of duty in Afghanistan with the U.S. Marines, with an honorable discharge in 2012 — and stressed that Tahmooressi needed to return to the United States for treatment. Tahmooressi had been diagnosed with PTSD shortly before his arrest and started treatment at the Veterans Affairs Medical Center in La Jolla.

Fernando Benítez, Tahmooressi’s Tijuana defense attorney, used a range of tactics to win his release. He initially pressed for dismissal of the case because his client’s rights were allegedly violated when he was held at the El Chaparral Port of Entry for hours without the presence of an attorney or a translator.

But in recent weeks, the attorney focused on Tahmooressi’s PTSD in an attempt to win him a humanitarian release. Key testimony came from a prosecution witness, Dr. Alberto Pinzón Picaseño. The Mexico City psychiatrist interviewed Tahmooressi and concluded that he suffers from a condition that has him feeling in constant danger. The psychiatrist recommended treatment “by specialized persons in his country of origin.”

While Tahmooressi’s case made its way through Mexico’s federal court system, his supporters in the United States sought to apply political pressure on Mexico — and on the Obama administration, as they chastised U.S. officials for not speaking out publicly or pleading his case directly with Mexican President Enrique Peña Nieto.

Yet seven months after his detention, there are still unanswered questions about Tahmooressi’s story.

Zeta, the Tijuana newsweekly, was the first to report that on the day of his arrest, Tahmooressi had walked into Mexico from San Ysidro, and rented a room at the Hotel Nelson near the border, paying 309 pesos — about $24. He did not stay overnight, instead walking back across to San Ysidro, retrieving his truck at a parking lot — and driving into Mexico.

Mexican customs inspectors said they found a pistol in a pocket beneath the driver’s side window, and the other weapons also within reach.

“What really struck the customs and military personnel was that all the weapons were loaded,” said Alejandro González Guilbot, the Mexican customs administrator at the time. “By his not saying that he was a Marine or an ex-Marine, it’s natural that they found this very strange.”

After initially claiming that he never before had visited Mexico, he later admitted to having crossed four times before his detention, telling CNN’s Chris Cuomo that “I went with my friends a couple of times to Mexico just to hang out.”

Tahmooressi’s mother, Jill, said that the lawyer initially hired by the family coached her son to lie; the attorney declined to comment while the case was ongoing.

As proof that he crossed by mistake, supporters point to Tahmooressi’s 911 call from the border, telling an operator that he had not intended to cross.

Others point to inconsistencies in his account. Tahmooressi said in an interview with U-T San Diego that he tried to stop his vehicle before going through the customs gates at the port of entry, but a woman standing by the gates waved him through. Yet a Mexican customs surveillance video viewed by U-T San Diego shows him driving straight through.

Though U.S. supporters have stressed Tahmooressi’s military service, Mexican authorities have said that Tahmooressi was not acting in any official capacity at the time he crossed the border, and did not identify himself as a Marine.

“Mr. Tahmooressi entered Mexico as a civilian,” according to the only statement on the case issued by the Mexican Attorney General’s Office. “He was neither in uniform, nor was he on active duty, nor was he driving an official vehicle when he crossed the border.” The attorney general’s office maintained that the case was a neither a diplomatic nor political matter, but “strictly a legal issue which will be resolved by the Mexican federal courts.”

Tahmooressi might well have been in violation of the law north of the border as well had he been caught driving with weapons that were loaded and not properly stored. California law stipulates that all weapons must be unloaded while being transported, and handguns and assault weapons must be stored in a locked container. Non-concealable firearms such as shotguns and rifles are not required to be in a locked container, but must be unloaded, the law states.