West Yorkshire Police officers found the weapon and almost £14,000 worth of class A drugs when they searched Nathan Murphy's mum's home in Leeds.
Murphy was jailed for more than eight years after pleading guilty to drugs and firearms charges at Leeds Crown Court
Louise Pryke, prosecuting, said officers executed a search warrant at a house on Seaforth Place, Harehills, on September 21 this year.
Murphy was living at the property with his mother and five children were also living there.
The officers found two small shoulder bags on the first floor landing which contained three handguns.
One of the guns was forensically examined and found to be in working order.
Ms Pryke said the pistol fired blank rounds but it had been modified.
A ball bearing had been loaded into the gun which was capable of being fired if gas had been discharged from a blank round.
Officers found 20 cartridges for the weapon in a bag in the toilet.
Almost £14,000 worth of heroin and crack cocaine was found when the basement was searched.
A holdall containing £4,000 in cash was seized along with digital scales, a money counting machine and an industrial press used for packaging drugs.
Murphy's mother was arrested and interviewed but the defendant admitted responsibility for the offending.
Murphy told officers he had forced his way into his mum's home and had used the property for drug dealing and to store the weapon.
The 27-year-old pleaded guilty to possessing a prohibited firearm, possessing ammunition without a certificate, two counts of possessing a class A drug with intent to supply and possessing criminal property.
He has previous convictions for supplying drugs.
Anthony Sugare, mitigating, asked that Murphy be given credit for pleading guilty to the offences at the earliest possible opportunity.
He said: "In old fashioned parlance, he was bang to rights.
"He accepted it. He accepts that he will be getting a long sentence."
Murphy was jailed for eight years and four months.
Judge Neil Clark said: "An aggravating feature is that there were children living at the house.
"They should not be exposed to these things and the risk that they create."