U.S. Rep. Ileana Ros-Lehtinen, R-Fla., confirmed in a statement Friday night that Hammar had been released. She also said he was "back safely in the United States."
"These past few months have been an absolute nightmare for Jon and his family, and I am so relieved that this whole ordeal will soon be over," the congresswoman said. " I am overcome with joy knowing that Jon will be spending Christmas with his parents, family and friends."
She thanked those "who have shown unwavering support for Jon and his family in their time of need, and who have been so instrumental in making this happen."
An aide to a legal representative of the Mexican attorney general's office had told U.S. Sen. Bill Nelson's staff about the pending release after the Florida Democrat's office got word from Hammar's mother, according to a press release.
"No American should be in a Mexican jail for five months without being able to have his case in front of a judge," Nelson had said in that statement. "We're grateful; this is a good Christmas present."
Earlier Friday, Varon Levy said he was flying from Mexico City to Matamoros to pick up his client. After that, the attorney said, they intended to cross the border. "I'm very happy. I feel that the Mexican legal system came out the way it should have," he said.
U.S. immigration and State Department officials had been at the Mexican detention center waiting for Hammar's release.
A defense lawyer said Mexican authorities determined there was no intent to commit a crime, Nelson's office said. The senator was among a handful of elected officials who urged the State Department to help get Hammar out of Mexico. His family said he was being held in isolation after they received threats to his safety.
Varon Levy said the path for Hammar's return was cleared when Mexican officials decided not to appeal the judge's ruling.
Civilian gun ownership is illegal under Mexican law unless the owner purchases the weapon from a special shop run by the country's Department of Defense.
"The Department of State warns all U.S. citizens against taking any type of firearm or ammunition into Mexico," the U.S. Embassy in Mexico writes on its website. "Entering Mexico with a firearm, certain types of knives, or even a single round of ammunition is illegal, even if the weapon or ammunition is taken into Mexico unintentionally."
Mexican law also bans shotguns with barrels of less than 25 inches. The family said Hammar's shotgun has a barrel of 24 inches.
Tourists are allowed to bring guns for hunting on rare occasions, but Mexican officials said all visitors must receive a special permit before entering the country. Mexican customs agents do not issue gun permits. As a result, anyone crossing the border with a firearm or ammunition without a previously issued government permit is in instant violation of Mexican law, which stipulates long jail terms for breaking weapons laws.
Hammar and his friend were on their way to Costa Rica in August and planned to drive across the Mexican border near Matamoros in a Winnebago filled with surfboards and camping gear. Hammar, 27, asked U.S. border agents what to do with the unloaded shotgun. His family said agents told them to fill out a form for the gun, which belonged to Hammar's great-grandfather.
But when the pair crossed the border and handed the paperwork to Mexican officials, they impounded the RV and jailed the men, saying it was illegal to carry that type of gun. Hammar's friend was later released because the gun did not belong to him.
Varon Levy said he was not sure of Hammar's immediate plans once he returns to the U.S. "Probably some down time," he said.