Graham Bryden's brother Jason died in a violent attack on 4 July in Kilmarnock.
Police raided the 45-year-old's home in the town on 7 July following a tip-off and found a black Taurus revolver, ammunition and heroin worth Â£2,590.
Bryden was jailed for five years and eight months after he admitted possessing the gun, bullets and heroin.
Jailing Bryden at the High Court in Glasgow, judge Lord Burns told him: "I have no reason to suppose your possession of these items was in connection with the drugs operation you were conducting from your house.
"The possession of a gun and ammunition was in some marginal respect as a result of the assault on and death off your brother."
The court heard that police raided Bryden's home in Kilmarnock three days after his brother's death.
Advocate depute Paul Brown, prosecuting, said: "Police were concerned about the prospect of an attempt by the accused to exact retribution on the men accused of committing this crime.
"There was further information available to the police that the accused was also dealing in drugs."
The court heard that Bryden's home was searched and the handgun was found on top of a cabinet in the kitchen, alongside a black zipped bag containing nine rounds of ammunition.
Nine wraps of heroin were found under a rug in the lounge and another in the tumble dryer.
Mr Brown told the court: "The revolver was in working order, but it was in a condition that could have been hazardous to the person firing it. In the opinion of expert it could case a potentially lethal injury if fired at a person."
The brother of an alleged murder victim has been jailed for possessing a hand gun and ammunition which police feared may have been used in a revenge attack.