Jaswant Singh Chail, 20, has also been charged with threats to kill and possession of an offensive weapon.
Mr Chail, from Southampton, is in custody and will appear at Westminster Magistrates' Court on 17 August.
The charges were brought after an investigation by the Metropolitan Police's Counter Terrorism Command.
Mr Chail was arrested at about 08:30 GMT on Christmas Day. The Met said he was stopped "within moments" of entering the grounds and he did not enter any buildings.
He has been charged with an offence under section 2 of the 1842 Treason Act, namely "discharging or aiming firearms, or throwing or using any offensive matter or weapon, with intent to injure or alarm her Majesty", said Scotland Yard.
The Queen had been staying at Windsor Castle for Christmas, rather than spending it as usual on her Sandringham estate in Norfolk.
Her Majesty was due to be joined for lunch by the Prince of Wales and the Duchess of Cornwall, as well as the Earl and Countess of Wessex.
Under the 1842 Treason Act, it is an offence to assault the Queen, or have a firearm or offensive weapon in her presence with intent to injure or alarm her or to cause a breach of peace.
In 1981, Marcus Sarjeant was jailed for five years under the section of the Treason Act after he fired blank shots at the Queen while she was riding down The Mall in London during the Trooping the Colour parade.