MIAMI - A Marine veteran jailed for months in Mexico after trying to carry a family-heirloom shotgun across the border has been freed, U.S. officials and his lawyer said late Friday.

The lawyer for Jon Hammar, 27, tweeted that his client had been released from a detention center in Matamoros.

"Jon is out, going home!" Eddie Varon Levy tweeted.

Patrick Ventrell, acting deputy spokesman for the State Department, confirmed the release.

"Officials from the U.S. Consulate General in Matamoros met him at the prison and escorted him to the U.S. border, where he was reunited with members of his family," the statement said. "We sincerely appreciate the efforts on the part of Mexican authorities to ensure that an appropriate resolution was made in accordance with Mexican law, and that Mr. Hammar will be free to spend the holidays with his loved ones."

An aide to a legal representative of the Mexican attorney general's office had told 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 from Nelson's office.

A defense lawyer said Mexican authorities determined there was no intent to commit a crime, Nelson's office said. His family had said he was being held in isolation after threats to his safety were received.

The lawyer, 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.

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 prison terms for breaking weapons laws.