Judge advocate Jeff Blackett told Danny Nightingale, who wore his SAS uniform in the courtroom, that his stories about how the gun came to be in his room "lacked credibility".
But he said there were "exceptional circumstances" that allowed the court to suspend the sentence "because of your exceptional character".
The judge also said that "criticism of the prosecution and the Army is unmerited and totally without foundation".
We understand how difficult these proceedings have been for you and your family. However, you have brought much of that anguish upon yourself and your public assertions that you are scapegoat or the victim of some wider political agenda is absolute nonsense.
You are simply someone against whom there was a strong prima facie case of serious wrongdoing and, given the dangers to society caused by illegal firearms and their misuse, it was in the public interest to prosecute you.
You have now had a fair trial before a civilian judge and an independent and impartial board.
SAS sniper Danny Nightingale is enjoying his first weekend at home after being released from jail following his appeal victory.
The 37-year-old received a hero's return as he arrived back at his home in Crewe late last night, with family and friends gathered alongside a large "Welcome Back" banner.
Sergeant Nightingale told reporters he would spend the weekend with his family before renewing the fight to clear his name.
Sgt Nightingale was originally given 18 months' military detention for illegally possessing a pistol and ammunition, before three appeal judges cut the term to a suspended 12 months on Thursday, prompting his release.
SAS Sergeant Danny Nightingale, who was freed after having his 18-month sentence for illegally possessing a gun reduced on appeal, has told ITV News that he held onto the weapon for so long because of "the hectic pace of life."
He said: "I'd just brought my best friend home in a coffin. It was an emotional period."