A passenger jailed after a gun was found in his carry-on luggage at Heathrow Airport can be released from prison after a challenge against his sentence at the Court of Appeal.

Rogelio Ahumada Y Otero claimed he did not know the working automatic pistol, a loaded magazine and loose cartridges were in the pockets of his suitcase as it passed through a scanner ahead of him boarding a commercial flight on May 7.

The Mexican national, who said the weapon and ammunition lawfully belonged to him, had been due to fly to Madrid with his wife, having travelled from Mexico City to Paris and on to London by Eurostar in the previous week.

On June 5, Ahumada Y Otero, then aged 74, pleaded guilty to possessing a prohibited firearm and possessing ammunition without a firearm certificate.

He was sentenced to a total of 26 months in prison at Isleworth Crown Court on June 15, after telling Judge Robin Johnson the incident “was accidental and happened because of completely innocent carelessness”.

Judge Johnson jailed the Mexican despite accepting he was “a man of exemplary character”, having received references from “a Nobel laureate for peace, a former ambassador and the president of the Mexico City Supreme Court”.

Lawyers for Ahumada Y Otero brought a bid to challenge his sentence at a Court of Appeal hearing in London earlier this month and in a written ruling on Wednesday judges ruled it was “manifestly excessive”.

Mrs Justice Ellenbogen, who sat with Lady Justice Thirlwall and Mr Justice Wall, replaced it with a total sentence of two years, suspended for two years, and said Ahumada Y Otero “can be released”.

At the original sentencing, Judge Johnson had said: “I find it very surprising the gun was not detected at either Mexico City or Paris.”

He told Ahumada Y Otero he “could not be sure you knew the gun was in that bag” and took into account “my finding that you were not aware that you were carrying a prohibited weapon”.

Ahumada Y Otero told police in a statement that the bag containing the gun was one he used when travelling to his country house in Mexico.

He said that after returning to Mexico City he asked a maid if she had seen the gun and was told it had probably been left at the cabin. Ahumada Y Otero said he searched the bag and could not find the weapon.

He later told the judge the weapon was stiff and he put it in his case to be oiled and serviced on return to Mexico City. Ahumada Y Otero said he presumed he had left it at the cabin after the maid said she had not found it.

The prosecution said there was no intention to use the weapon.

Judge Johnson said: “In my judgment you have brought the gun back and recklessly left it in a bag that you later used for international travel some two to three weeks later.”

The judge acknowledged the Mexican was “a hugely experienced traveller who would be well aware of security measures at travel hubs such as London Heathrow”, had “poor health” and was “a good man who has contributed to many people, charities and good causes”.

He said there were “exceptional circumstances”, but added that “taking a bag on to a scheduled flight with a prohibited weapon and compatible ammunition is clearly a very serious offence” and concluded “only an immediate custodial term could do justice to this case”.

At the appeal hearing earlier this month, Richard Kovalevsky KC, for Ahumada Y Otero, said his sentence should have been suspended, telling judges there was no suggestion the prohibited items were possessed in a criminal context and that he was ignorant of them being in the luggage.

Mrs Justice Ellenbogen said Judge Johnson had taken the “wrong” approach to sentencing, ruling that in the “very unusual circumstances” of the case, “appropriate punishment” could be achieved through a suspended sentence.