Police found a loaded handgun hidden in a ‘secret compartment’ during a raid at a house in Leeds.
Officers discovered a Luger pistol, loaded with six bullets, after following Tyrone Lewis to the property in Halton Moor.
Lewis, 31, was jailed for six years at Leeds Crown Court after pleading guilty to possession of a prohibited firearm and ammunition with intent to endanger life.
The discovery was made outside the property on Carden Drive on July 20 last year, after police followed Lewis and two other men to the address.
Lewis was followed by officers as he had been involved in stealing a mobile phone from a man the previous day, the court heard.
The weapon was found in a bag hidden outside the house beneath two gas meter box panels.
The bag also contained further rounds of ammunition, a balaclava and the mobile phone which had been stolen the previous day.
Lewis, of Spencer Place, Chapeltown, has previous convictions for drug dealing and possessing ammunition.
Jailing Lewis, Recorder of Leeds Judge Guy Kearl QC, said: “The unlawful possession of guns and ammunition is a grave source of danger for our society.
“They are used to kill and maim people - often innocents on the streets.
“They are used in the commission of other serious criminal offending, either to harm or intimidate. That is why criminals possess them.
“Those who possess firearms with the intent to endanger life must expect to receive lengthy deterrent sentences.”
Kara Frith, mitigating, said Lewis fully accepted responsibility for the offences and accepted he must face a lengthy prison sentence.
Ms Frith said Lewis knew the person who lived at the house and left the weapon there “for safe keeping.”
She added: “He doesn’t want to involve anyone else or say where he got the weapon from.
“He knows there is a price to pay for his stupidity.”
Ms Frith said the father-of-two wanted to address his offending behaviour while in custody.