The first device identified as a gun, a bamboo tube that used gunpowder to fire a spear, appeared in China around AD 1000.[2] The Chinese had previously invented gunpowder in the 9th century.[4][5][6][full citation needed]
An early type of firearm or portable gun is the fire lance, a black-powder filled tube attached to the end of a spear and used as a flamethrower; shrapnel was sometimes placed in the barrel so that it would fly out together with the flames.[6][full citation needed][7][full citation needed] The earliest depiction of a gunpowder weapon is the illustration of a fire-lance on a mid-10th century silk banner from Dunhuang.[8] The De'an Shoucheng Lu, an account of the siege of De'an in 1132, records that Song forces used fire-lances against the Jurchens.[9]
In due course, the proportion of saltpeter in the propellant was increased to maximise its explosive power.[7][full citation needed] To better withstand that explosive power, the paper and bamboo of which fire-lance barrels were originally made came to be replaced by metal.[6] And to take full advantage of that power, the shrapnel came to be replaced by projectiles whose size and shape filled the barrel more closely.[7][full citation needed] With this, we have the three basic features of the gun: a barrel made of metal, high-nitrate gunpowder, and a projectile which totally occludes the muzzle so that the powder charge exerts its full potential in propellant effect.[10]
Breech-loading guns called cetbang were used by the Majapahit Empire during the conquest of Nusantara in 1336-1350. The knowledge of making powder weapons in Java is thought to have originated from the Mongol invasion in 1293.[11] These swivel guns mounted on various vessels of the Majapahit navy were used to great effect against traditional boarding-style warfare of other kingdoms in the archipelago.[12]
One theory of how gunpowder came to Europe is that it made its way along the Silk Road through the Middle East another is that it was brought to Europe during the Mongol invasion in the first half of the 13th century.[13][full citation needed][14][full citation needed] English Privy Wardrobe accounts list ribaldis, a type of cannon, in the 1340's, and siege guns were used by the English at Calais in 1346.[15] The earliest surviving[clarification needed] firearm in Europe has been found from Otepää, Estonia and it dates to at least 1396.[16]
Around the late 14th century in Europe, smaller and portable hand-held cannons were developed, creating in effect the first smooth-bore personal firearm. In the late 15th century the Ottoman empire used firearms as part of its regular infantry.
The first successful rapid-fire firearm is the Gatling Gun, invented by Richard Gatling and fielded by the Union forces during the American Civil War in the 1860's.
The world's first sub-machine gun a fully automatic firearm which fires pistol cartridges able to be maneuvered by a single soldier is the MP18.1, invented by Theodor Bergmann. It was introduced into service in 1918 by the German Army during World War I as the primary weapon of the Stosstruppen assault groups specialized in trench combat.
The first assault rifle was introduced during World War II by the Germans, known as the StG44. It was the first firearm which bridges the gap between long range rifles, machine guns, and short range sub-machine guns. Since the mid-20th century guns that fire beams of energy rather than solid projectiles have been developed, and also guns that can be fired by means other than the use of gunpowder.