A handgun and more than 300 rounds of ammunition were recovered when police raided the quarters of an SAS sniper, a court heard on Tuesday.
Sergeant Danny Nightingale, 38, a special forces veteran who has served more than 18 years in the military, is accused of possessing a Glock 9mm pistol and 338 rounds of ammunition.
A court martial at Bulford, Wiltshire, was told that the handgun and ammunition were recovered when civilian police searched the father-of-two's accommodation, which he shared with another soldier, known only as Soldier N.
Timothy Cray, prosecuting, told the five-strong court martial board: "The Crown's case put shortly is that the defendant's possession of the firearm and ammunition was in breach of standing orders that are familiar to every soldier and fundamentally was contrary to the law of this country.
"We say there is no excuse for what the defendant did.
"No matter how he tries to deny it, the gun and ammunition were there in his bedroom because he put them there and he kept them there."
Sgt Nightingale, of Crewe, Cheshire, has pleaded not guilty to a charge of possession of a prohibited firearm, namely a Glock 9mm pistol, between 26 November 2007 and 16 September 2011.
He also denies possession on or about 16 September 2011 of ammunition, namely 122 9mm live rounds, 40 7.62mm live rounds, 50 9mm frangible rounds, 50 .338 armour piercing live rounds, two .308 live rounds and 74 5.56mm live rounds.
Sgt Nightingale's family, including wife Sally and father Humphrey, were in court to support him.
Cray continued: "The court will be aware that the strict policy of the Army and the law in relation to weapons and ammunition are because of the dangers to life and public safety that arise if this weapon and ammunition fall into the wrong hands.
"Those dangers were particularly acute in this case given the quantity of 9mm rounds that were stored in the same room as the gun.
"Public safety is protected by proper systems of secure storage and accountability for weapons and ultimately soldiers obeying orders.
"On the specific facts alleged - that is, the defendant's attitude to the retention of arms and ammunition - is that he made a series of mistakes that put the public at risk and that is why he now comes before this court martial."
Cray said Sgt Nightingale had given "various explanations" for how he came into possession of the pistol and ammunition.
"He first said that he got the gun in Iraq in 2007, that he brought it back to this country intending to present it to his unit as a trophy, but then somehow never got round to completing that task during the four years that he has the gun in the UK," Cray said.
"He also said that he had accumulated the ammunition because he was a range instructor and, over the years, it had built up through poor administration and repeated failures to book it make into the secure stores or to put it in an amnesty bin."
Cray told the board that Sgt Nightingale would now be inviting the court to consider that his earlier explanations were "unreliable" and that "someone else could have put the gun in his wardrobe and the ammunition under his bed".
Cray said: "The claim of unreliability is said to be a result of memory difficulties that affected the defendant and he collapsed while participating in a jungle marathon in Brazil in October 2009.
"These will be issues to consider in due course but the Crown's case is that there is no proper basis for the defendant being able to say having false memory in relation to the pistol or ammunition."
The court martial was told that Sgt Nightingale, whose regiment in court was listed as The Duke of Lancaster's Regiment (King's, Lancashire and Border), returned to full duty with his special forces unit in January 2010 and passed all assessments to be deployed to Afghanistan in May 2011.
"He made no complaint of memory loss at the time of his interviews and we suggest that what he is saying now is wholly inconsistent with his record of service since the injury and is untrue," Cray said.
Cray said Sgt Nightingale's case had attracted a "wide degree of public interest and press attention, arising in part from the mystique that surrounds the unit and the necessary secrecy that cloaks its operations".
The prosecutor added: "The Crown suggests however that there is nothing very mysterious about this case.
"It turns on the common-sense propositions that a solider is, or should be, responsible for his own kit... as you will be directed, there is no middle ground or grey area when it comes to the possession of firearms and ammunition.
"If the defendant obtained the pistol, as he said, in Iraq but had forgotten about it, that is no defence in law to the charge of possessing a firearm. The same applies to forgetting about the ammunition."
The court heard that Sgt Nightingale's accommodation, which cannot be identified for legal reasons, was searched by police after an allegation was made against Soldier N.
This serviceman, who was in the same unit as Sgt Nightingale, pleaded guilty to Firearms Act offences after a weapon, ammunition and hand grenade were recovered from the property.
He was given a sentence of military detention, which he is serving, Cray said.
The prosecutor said that several witnesses from the SAS would be giving evidence during the court martial - known only as Soldiers A, B and Y.
The prosecutor said that when Sgt Nightingale was arrested and interviewed in September 2011, he admitted possession of the firearm and ammunition.
Cray said that, in an interview in January last year, this time with the Royal Military Police, Sgt Nightingale "clarified" that he was given the pistol as a personal gift by a group of Iraqi nationals he had been working with and that he intended to give the weapon to his unit as a leaving gift.
"During the interviews he sought to excuse his actions by saying that his failure to comply with the proper procedures was down to oversight," Cray said.
"He made several references to the 'hectic' nature of his schedule and the last-minute nature of packing his kit before deployments.
"If the defendant is claiming that, in 2011, he missed seeing the weapon and the ammunition through oversight or through being away from his base, the Crown suggests that this claim does not stand up to analysis.
"In interview the defendant accepted that he had every opportunity to surrender the ammunition and to deal appropriately with the pistol."
The court martial heard that Sgt Nightingale and Soldier N had been friends for several years but their friendship ended after the defendant asked him in October last year to provide a statement saying he had helped him move into their shared accommodation.
"By implication (he) could have been responsible for moving the pistol into the bedroom," Cray said.
Summarising, Cray said it was for the board to determine fact and on that basis whether Sgt Nightingale was guilty or not guilty.
"We suggest that the questions that the evidence in this case raises and the matter are straightforward.
"Did the defendant put the gun and the ammunition in his bedroom or did somebody else put it there?
"If the gun and ammunition belonged to somebody else, how did the defendant miss it?
"Is the claim of memory loss in respect of the gun and ammunition the truth or a lie told to try and avoid the consequences of the truth?"
The trial continues.