History of the firearm
Firearms were invented in the 14th century in China, after the Chinese had invented gunpowder in the 9th century. These inventions were later transmitted to the Middle East, Europe, and Africa.
Firearms in China
The direct ancestor of the firearm is the fire lance, a black-powder–filled tube attached to the end of a spear and used as a flamethrower (not to be confused with the Byzantine flamethrower); shrapnel was sometimes placed in the barrel so that it would fly out together with the flames. The earliest depiction of a gunpowder weapon is the illustration of a fire-lance on a mid-12th century silk banner from Dunhuang. 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.
In due course, the proportion of saltpeter in the propellant was increased to maximise its explosive power. To better withstand that explosive power, the paper and bamboo of which fire-lance barrels were originally made came to be replaced by metal. 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. 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.
The earliest depiction of a gun is a sculpture from a cave in Sichuan dating to the 12th century of a figure carrying a vase-shaped bombard with flames and a cannonball coming out of it. The oldest surviving gun, made of bronze, has been dated to 1288 because it was discovered at a site in modern-day Acheng District where the Yuan Shi records that battles were fought at that time; Li Ting, a military commander of Jurchen descent, led foot-soldiers armed with guns—including a Korean brigade—in battle to suppress the rebellion of the Christian Mongol prince Nayan.
Firearms in Southeast Asia
The first recorded firearms in Vietnam Đại Việt were used against the Champa king Chế Bồng Nga in 1390. He was killed by a volley of cannons known in Chinese as Huochong, one cannonball blasted through the ship planks before hitting the king and causing his instant death 
Decades later, the Lê dynasty established their standing army, including two battalions who were primarily equipped with the Huochong. These battalions were later renamed "Thần Lôi" (Divine Thunder) and "Thần Điện" (Divine Lightning) for the prowess of their firearms.
Firearms in the Middle East
The Arabs obtained firearms in the 14th century. Al-Hassan claims that the Battle of Ain Jalut in 1260 saw the Mamluks use against the Mongols "the first cannon in history" gunpowder formulae which were almost identical with the ideal composition for explosive gunpowder. However, Khan states that it was invading Mongols who introduced gunpowder to the Islamic world and cites Mamluk antagonism towards early riflemen in their infantry as an example of how gunpowder weapons were not always met with open acceptance in the Middle East.
Firearms in Europe
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. English Privy Wardrobe accounts list "ribaldis," a type of cannon, in the 1340s, and siege guns were used by the English at Calais in 1346.
The first mention of firearms in Russia is found in the "Sofiiskii vremennik" chronicle, where it is stated that during the 1382 defense of Moscow from Tokhtamysh's Golden Horde, Muscovites used firearms called "tiufiaks" (Russian: "тюфяки", which were of Eastern origin; this word derives from Turkic "tüfeng", meaning "gun").
Around the late 13th century in Italy, smaller and portable hand-held cannons or schioppo 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.
Early modern age
Early firearms had to be cocked and caught by the "sear", which holds the hammer back, before each shot. Pulling the trigger allows the hammer or striker to fly forward, striking the "firing pin," which then strikes the "primer," igniting an impact-sensitive chemical compound (historically, first fulminate of mercury, then potassium chlorate, now lead styphnate) which shoots a flame through the "flash hole" into the cartridge's propellant chamber, igniting the propellant.
The Springfield Armory in Springfield, Massachusetts became important to the history of firearms during the 1850s, when it debuted the Springfield rifle. Springfield rifles were among the very first breech-loading rifles, starting production in 1865. By that time, metallurgy had developed sufficiently so that brass could be worked into fixed ammunition. Previously, each round was custom made as needed: the shooter poured loose powder down the barrel, used leather or cloth for wadding if time allowed, selected a suitable projectile (lead ball, rocks, arrow, or nail), then seated the projectile on top of the powder charge by means of a ramrod. Performance was erratic. Fixed ammunition combined a primer, the pre-measured charge, and the projectile in a water-resistant brass cartridge case. Most importantly, the soft brass expanded under pressure of the gas to seal the rear end of the barrel, which prevented the shooter from being maimed by escaping high-pressure gases when he pulled the trigger.
Repeating and automatic firearms
A repeating firearm or "repeater" is a firearm that holds more than one cartridge and can be fired more than once between chargings. The most well-known repeater is the American Springfield Model 1892-99—also made at the Springfield Armory in Springfield, Massachusetts—which were used during the Spanish-American War. Some repeating firearms require manipulation of a bolt (as in bolt action), lever, or slide to eject the fired cartridge case, draw a fresh cartridge from the magazine, and insert it into the firing chamber, and "cock" (draw to the rear and place under spring tension) the hammer or striker, so that pulling the trigger will fire the weapon. Others use either the firearm's recoil, or a small portion of the propellant gas drawn from the barrel, to operate the firearm's mechanism and ready it for the next shot. Such firearms are sometimes called "self-loading," but are more commonly known as semi-automatic, if they fire one shot for every pull of the trigger, or automatic or "full-auto" if they continue to fire until the trigger is released and/or the magazine is empty.
A revolver is a unique type of firearm in which a rotating cylinder holds a number of cartridges; the cylinder "revolves" to align each "chamber" or "charge hole" with the rear of the barrel, hold the cartridge and contain the pressure (up to 65,000 pounds per square inch or 450 MPa) produced when the cartridge is fired. Thus the cylinder serves as both magazine and firing chambers. There are also "single- shot" and multiple-barrel firearms, which hold only one cartridge per barrel and must be reloaded manually between shots.
The earliest repeating firearms were revolvers (revolving rifles were sometimes called "turret guns") and were "single action" in that they could only be fired one way: by manually cocking the mechanism (drawing the hammer to the rear with the thumb) before each shot. This design dates from 1836, with the introduction of the Colt Paterson, or even earlier. Though they are slower to reload and fire than some other types of firearms, single-action revolvers are of a simple, strong design, and are still made, though they are nowadays used more often for hunting than for self-defense. The double-action revolver is a design almost as old as the single action. A double-action revolver can be fired in either of two ways. One can cock the hammer (the action of which moves levers to rotate the cylinder and align a fresh cartridge with the rear of the barrel), then pull the trigger for each shot ("single-action mode") or one may simply pull the trigger, through a longer, heavier stroke. This causes levers and springs to both rotate the cylinder and draw the hammer to the rear, then release it, firing the cartridge. Firing a double-action revolver in single-action mode tends to be more accurate, because the trigger pull is much shorter and lighter; usually three or four pounds-force (18−22 newtons) of pull is sufficient, instead of the twelve to twenty pounds (50−90 N) required for double-action mode, so the firearm's aim and mobility is less likely to be disturbed by the force of pulling the trigger.
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 1860s. It is operated by a hand crank and rotates multiple barrels. The Gatling Gun needs a four man crew to function and has had many upgrades since its introduction and has been used in many conflicts.
Self-loaders are firearms that use some of the discharge energy to reload the firearm. These are also called semi or full-automatics. These are typically fed from a tube or detachable magazine, commonly but incorrectly referred to as a “clip” (which correctly denotes a magazine reloading device used in certain rifles, or a retainer for flangeless bullets used in certain revolvers). The world's First self-loading firearm is the Maxim machine gun, developed by British inventor Sir Hiram Stevens in 1884, capable of firing 600 rounds per minute but requires a team of men to maintain and is not portable by one man. The Maxim gun has been used in a vast number of conflicts.
The world's first successful self-loading rifle is the Mondragón rifle, designed by Mexican general Manuel Mondragón and was the first automatic firearm able to be operated by a single rifleman, since its debut in 1887 it has gone through a series of improvements and has been used in many wars ranging from the Mexican Revolution to World War 1 by Germany, and has been in many other conflicts including the Vietnam War.
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 The Stosstruppen (assault groups specialized in trench combat).
The first Assault Rifle was introduced during WWII by the Germans, known as the StG44, it was the first-ever firearm which bridges the gap between long range rifles, machine guns and short range sub-machine guns. More powerful and with longer range than a sub-machine gun, yet can be used comfortably in close, urban environments and on fully automatic from the shoulder unlike heavier machine guns and long semi-auto rifles, thanks to its intermediate round and select-fire option (switch from fully automatic to semi automatic). After WW2 ended, the Assault Rifle concept was adopted by every world power and is still being used to this day.
- Lu, Needham & Phan 1988
- Buchanan 2006, p. 2 "With its tenth century AD origins in China, the knowledge of gunpowder emerged from the search by alchemists for the secrets of life, to filter through the channels of Middle Eastern culture, and take root in Europe with consequences that form the context of the studies in this volume."
- Needleham 1986, p. 7 "Without doubt it was in the previous century, around +1850, that the early alchemical experiments on the constituents of gunpowder, with its self-contained oxygen, reached their climax in the appearance of the mixture itself."
- Chase 2003, pp. 31–32
- Crosby 2002, p. 99
- Needham 1986, pp. 8–9
- Needham 1986:222
- Needham 1986, p. 10
- Chase 2003:31–32
- Needham 1986:293–294
- Chinese Gunpowder Technology Technology and Dai Viet, ca. 1390 -1497. Sun Laichen. In Vietnam Borderless Histories Eds Hnung Tuyet Tran & Anthony Reid, University of Wisconsin Press 2006
- Chase 2003:1 "The Europeans certainly had firearms by the first half of the 1300s. The Arabs obtained firearms in the 1300s too, and the Turks, Iranians, and Indians all got them no later than the 1400s, in each case directly or indirectly from the Europeans. The Koreans adopted firearms from the Chinese in the 1300s, but the Japanese did not acquire them until the 1500s, and then from the Portuguese rather than the Chinese."
- Ahmad Y Hassan, Gunpowder Composition for Rockets and Cannon in Arabic Military Treatises In Thirteenth and Fourteenth Centuries, History of Science and Technology in Islam.
- Ahmad Y Hassan, Technology Transfer in the Chemical Industries, History of Science and Technology in Islam.
- Khan, Iqtidar Alam (1996), "Coming of Gunpowder to the Islamic World and North India: Spotlight on the Role of the Mongols", Journal of Asian History 30: 41–5.
- Khan, Iqtidar Alam (2004), Gunpowder and Firearms: Warfare in Medieval India, Oxford University Press.
- Norris 2003:11
- Chase 2003:58
- David Nicolle, Crécy 1346: Triumph of the longbow, Osprey Publishing; June 25, 2000; ISBN 978-1-85532-966-9.
- Firearms in Russia
- (Russian) First Gun Volleys
- Ain Mäesalu: Otepää püss on maailma vanim
- Buchanan, Brenda J. (2006), Gunpowder, Explosives and the State: A Technological History, Aldershot: Ashgate, ISBN 0-7546-5259-9
- Chase, Kenneth (2003), Firearms: A Global History to 1700, Cambridge University Press, ISBN 0-521-82274-2
- Crosby, Alfred W. (2002), Throwing Fire: Projectile Technology Through History, Cambridge University Press, ISBN 0-521-79158-8
- Kelly, Jack (2004), Gunpowder: Alchemy, Bombards & Pyrotechnics: The History of the Explosive that Changed the World, Basic Books, ISBN 0-465-03718-6
- Needham, Joseph (1986), Science & Civilisation in China, V:7: The Gunpowder Epic, Cambridge University Press, ISBN 0-521-30358-3
- Norris, John (2003), Early Gunpowder Artillery: 1300-1600, Marlborough: The Crowood Press.
- Sun Laichen (2006) Chinese Gunpowder Technology Technology and Dai Viet, ca. 1390 -1497. In Vietnam Borderless Histories Eds Nhung Tuyet Tran & Anthony Reid University of Wisconsin Press
- Pyhrr, Stuart W. (1985). Firearms from the collections of the Prince of Liechtenstein. New York: The Metropolitan Museum of Art. ISBN 9780870994258.