A 21-gun salute is the most commonly recognized of the customary gun salutes that are performed by the firing of cannons or artillery as a military honor.
The custom stems from naval tradition, where a warship would fire its cannons harmlessly out to sea, until all ammunition was spent, to show that it was disarmed, signifying the lack of hostile intent. As naval customs evolved, 21 guns came to be fired for heads of state, or in exceptional circumstances for head of government, with the number decreasing with the rank of the recipient of the honor.
While the 21-gun salute is the most commonly recognized, the number of rounds fired in any given salute will vary depending on the conditions. Circumstances affecting these variations include the particular occasion and, in the case of military and state funerals, the branch of service, and rank (or office) of the person to whom honors are being rendered.
The tradition of saluting can be traced to the Late Middle Ages practice of placing oneself in an unarmed position and, therefore, in the power of those being honored. This may be noted in the dropping of the point of the sword, presenting arms, discharging cannon and small arms by firing them, lowering sails, manning the yards, removing the headdress or laying on oars.
The gun salute might have originated in the 17th century with the maritime practice of demanding that a defeated enemy expend its ammunition and render itself helpless until reloaded, a time-consuming operation. The gun salute had been established as a naval tradition by the late sixteenth century. A man-of-war which visited a foreign port would discharge all its guns to show that its guns were empty. Since the ship would not have enough time to reload before it was within range of the shore batteries, it was clearly demonstrating its friendly intentions by going in with empty guns.
Salute by gunfire is an ancient ceremony. For years, the British compelled weaker nations to render the first salute; but in time, international practice compelled "gun for gun" on the principle of equality of nations. In the earliest days, seven guns was the recognized British national salute because seven was the standard number of weapons on a vessel. In that day, gunpowder made from sodium nitrate was easier to keep on dry land than at sea. Thus those early regulations stated that although a ship would fire only seven guns, the forts ashore would fire three shots to each one shot afloat, hence the number 21.