The owners of Wonderland were told to install safety measures if they wanted to continue selling the weapons, after a change in the law last year.
The Lothian Road shop was Scotland's largest seller of air weapons with sales of around 50,000 per year.
However, Lothian and Borders chief constable David Strang dismissed the application, saying he considered the store to be a toy shop.
But today a sheriff insisted Mr Strang had got it wrong and ordered the police to reverse the decision.
In a written judgement, Sheriff Kenneth Maciver said: "The Chief Constable has again misjudged the precise nature of Wonderland's business and has categorized the shop as a toy shop, and as such likely to be populated only by hoards of unaccompanied small children who would be free to roam the shop and without restriction or obstruction the weapons."
Iain Reid, manager of Wonderland, said: "We're obviously very pleased with the judge's decision and hope we can now move on from this."