Yanira Maldonado, 42, walked out of the prison on the outskirts of Nogales, Mexico and into her husband's arms late Thursday night.
She spoke briefly, thanking U.S. state department officials, her husband, her lawyers and prison workers who made her stay comfortable.
"Many thanks to everyone, especially my God who let me go free, my family, my children, who with their help, I was able to survive this test," she said.
The family's lawyer in Nogales, Jose Francisco Benitez Paz, said a judge determined Thursday that she was no longer a suspect and all allegations against her were dropped. The couple planned to immediately return to Arizona, he said.
"She lived through a nightmare," he said after her release.
Maldonado's release came hours after court officials reviewed security footage that showed the couple boarding a commercial bus traveling from Mexico to Phoenix with only blankets, bottles of water and her purse in hand.
U.S. politicians portrayed her as a victim of a corrupt judicial system and demanded her release with Arizona congressmen saying they were working closely with Mexican authorities. The office of Sen. Jeff Flake, R-Ariz., said earlier that he "has had multiple conversations with the deputy Mexican ambassador."
The judge had until late Friday to decide whether to free her or send her to another prison in Mexico while state officials continued to build their case. Prosecutors could appeal the ruling.
Maldonado was arrested by the Mexican military last week after they found nearly 12 pounds (5.4 kilograms) of pot under her seat during a security checkpoint.
Benitez noted that it was a fairly sophisticated smuggling effort that included packets of drugs attached to the seat bottoms with metal hooks - a task that would have been impossible for a passenger. He said witness testimony and the surveillance video showed Yanira Maldonado was innocent.
"There is justice in this country," he said.
Gary Maldonado said he was originally arrested after the pot was found under his wife's bus seat, but after Yanira Maldonado begged the soldiers to allow her to come along to serve as a translator, the military officials decided to release him and arrest her instead. He said authorities originally demanded $5,000 for his wife's release, but the bribe fell through.
"Here, we are guilty until you are proven innocent," he said after the court hearing.
The Maldonados were traveling home to the Phoenix suburb of Goodyear after attending her aunt's funeral in the city of Los Mochis when they were arrested.
The bus passed through at least two checkpoints on the way to the border without incident. In the town of Querobabi in the border state of Sonora, all the passengers were ordered off the bus and a soldier searched the interior as they waited. The soldier exited and told his superiors that packets of drugs had been found under seat 39, Yanira Maldonado's, and another seat, number 42. Her husband was in seat 40.
Gary Maldonado said a man sitting behind them on the bus fled during the inspection. He said the man might have been the true owner of the drugs.
About 40 people were on the bus before the inspection, but Gary Maldonado said he was the only passenger who appeared American.
Mexican officials provided local media with photos that they said were of the packages Maldonado is accused of smuggling. Each was about 5 inches high and 20 inches wide, roughly the width of a bus seat. The marijuana was packed into plastic bags and wrapped in tan packing tape.
The couple had previously traveled on commercial buses through Mexico because they felt it was safer than driving a personal vehicle.
Yanira Maldonado is a naturalized U.S. citizen who was born in Mexico, her family said. The couple celebrated their first wedding anniversary while she was jailed.
Drug traffickers have increasingly been using passenger buses to move U.S.-bound drugs through Mexico. Federal agents and soldiers have set up checkpoints along Mexico's main highways and have routinely seized cocaine, marijuana, heroin and more from buses.
Mexico's justice system is carried out largely in secret, with proceedings done almost entirely in writing.
Four years ago, Mexico decriminalized the possession of small amounts of marijuana, cocaine and heroin, but it still has stiff penalties for drug trafficking.
Mexican law doesn't specify a minimum or maximum sentence in drug crimes and leaves it up to the judge to decide how long the sentence should be, said Jose Luis Manjarrez, a spokesman for federal prosecutors in Mexico.
On Wednesday, an army lieutenant, a private and another sergeant were supposed to appear in court but they did not show up. The army did not explain why, the couple's lawyer said.
A search of court records in Arizona didn't turn up any drug-related charges against Yanira or Gary Maldonado.
The Maldonados said they will likely avoid future trips to Mexico.
"Maybe in time," she said.