The Chinese word for gunpowder is 火藥 (huǒyào), which translates as “fire medicine.” The name preserves the original purpose. Gunpowder was not invented as a weapon. It was discovered as a chemical accident in the course of medical and alchemical research, by practitioners of a religious-philosophical tradition that had been systematically experimenting with mineral combinations for several centuries in pursuit of two parallel goals: the transmutation of base metals into gold, and the formulation of a chemical substance that, when ingested by a human being, would grant immortality. The two goals were related. The general framework of Chinese alchemy, like the broadly contemporary tradition of European alchemy, held that the physical properties of matter could be transformed through the application of correct chemical procedures, and that the same principles governing the transformation of metals might also govern the transformation of the human body from its mortal to an immortal form. The alchemists pursued this programme by combining essentially every available natural substance with essentially every other available natural substance, heating the mixtures, observing the results, and recording which combinations produced which effects.

According to Britannica’s overview of gunpowder’s chemistry and historical origins, the specific combination that eventually produced gunpowder involves three ingredients. Saltpeter, also known as potassium nitrate, was called “Chinese snow” in Tang Dynasty alchemical texts and was considered to have spiritually significant properties because of its unusual chemical behaviour — it dissolves easily in water, recrystallises into geometrically perfect forms, and produces a vigorous oxidising reaction when heated. Sulfur, the yellow mineral the European tradition would later call “brimstone,” was associated in Chinese alchemy with the principle of vital fire and was already in widespread use in skin-disease and parasitic-infection treatments. Charcoal, the carbon-rich residue of partially-burned wood, was a routine material in alchemical kilns. None of the three substances, taken individually, behaves in an unexpected way. The combination, however — particularly when the saltpeter constitutes approximately 75 percent of the mixture, the sulfur approximately 10 percent, and the charcoal approximately 15 percent — produces a chemical reaction in which the saltpeter rapidly releases oxygen, the charcoal and sulfur rapidly combust in that oxygen, and a substantial quantity of hot gas is produced in a very short period of time. The result, in confined spaces, is an explosion.

The earliest written warning

The earliest surviving Chinese document that describes the explosive properties of the three-ingredient mixture is a Taoist alchemical text called the Zhenyuan Miaodao Yaolüe — “Classified Essentials of the Mysterious Way of the True Origin of Things” — which dates to approximately 850 CE, in the middle of the Tang Dynasty. The text is not a recipe for gunpowder. It is, in essential respects, the opposite of a recipe for gunpowder. As detailed in a published lecture by the Cambridge historian of science Joseph Needham on the development of gunpowder in medieval China, the text is a compilation of elixir recipes that the author considered too dangerous to recommend to practising alchemists. The relevant warning, translated from the classical Chinese by Needham, reads: “Some have heated together sulfur, realgar and saltpeter with honey; smoke and flames result, so that their hands and faces have been burnt, and even the whole house where they were working burned down.” The text is, in other words, a 9th-century health-and-safety document. The fact that an explicit warning against this particular ingredient combination existed in writing by 850 CE strongly suggests that the discovery itself had been made some time earlier, that multiple alchemists had been injured experimenting with the mixture, and that the broader alchemical community had begun circulating the information as a cautionary tale long before any practical application of the explosive properties had been considered.

Needham — whose multi-volume Science and Civilisation in China remains the definitive English-language academic treatment of the history of Chinese scientific and technological development — described gunpowder explicitly as the product of “the systematic if obscure investigations of Taoist alchemists” rather than of any military or engineering research programme. The alchemists who made the original discovery had no apparent interest in weaponising it. They had been looking for the substance that would prevent death. They had found a substance that produced fire, smoke, and injury. From their perspective, this was a failed experiment — a chemical combination to be added to the list of things one should not, under any circumstances, attempt to ingest. The mixture remained, for approximately the next half-century, a curiosity. It was used in entertainment contexts, in some preparations as a skin treatment, and as a fumigant. It was not yet, in any sense that a 9th-century reader would have recognised, a weapon.

How it became a weapon

The transition from accidental alchemical discovery to systematic military application took approximately a century. As described in a Clemson University academic resource on gunpowder in medieval China that draws on Needham’s authoritative treatment of the subject, the first documented military use occurred in the late 9th to early 10th century, with gunpowder-based “flying fires” or fire arrows appearing in late-Tang military records. The systematic weaponisation of gunpowder began in earnest under the Song Dynasty (960-1279 CE), which faced sustained military pressure from the Khitan Liao, the Tangut Western Xia, and ultimately the Jurchen Jin and the Mongol Empire — each of which made conventional defensive warfare increasingly difficult and provided substantial incentive to develop unconventional alternatives. Song military engineers progressively refined the gunpowder formula, developing fire arrows, fire lances (a kind of proto-flamethrower mounted on a pole), early bombs (the “thunderclap” and “heaven-shaking” varieties), incendiary devices, smoke-screen weapons, and eventually, in the 13th century, the first true firearms.

The earliest published gunpowder formulas — three of them, all developed for military use — appear in a Northern Song military encyclopedia called the Wujing Zongyao (武經總要, “Complete Essentials for the Military Classics”) compiled between 1040 and 1044 CE. Per an EBSCO research summary of the invention of gunpowder and the development of early firearms, the three formulas specified in the text contained substantially less saltpeter than the optimal proportion for explosive propulsion — closer to 50 to 55 percent rather than the eventual 75 percent — which means they functioned more as incendiary devices than as the true propellants that later gunpowder formulations would become. The optimisation took several more centuries. By the 13th century, gunpowder weapons had spread west across Eurasia via the Mongol conquests, with written formulas appearing in the Middle East between 1240 and 1280 in a treatise by the Syrian chemist Hasan al-Rammah, and in Europe by 1267 in the Opus Majus of the English friar Roger Bacon. By the 14th century, the first European cannons were being manufactured. By the 16th century, the firearm had displaced the bow and the crossbow as the dominant infantry weapon of European warfare. By the 19th century, gunpowder-based explosives were being used to blast tunnels through mountains, demolish buildings, and reshape the physical landscape of the planet on a scale that would have been inconceivable to the Tang Dynasty alchemists who had originally discovered the substance.

The historical irony, which the literature on gunpowder has remarked on extensively over the past several centuries, is that the substance that has been more directly responsible for the deaths of human beings in warfare than any other single chemical compound was discovered by people whose entire research programme was organised around the goal of preventing human death. The alchemists pursuing the elixir of immortality had not, in any sense, succeeded — no Taoist practitioner achieved physical immortality through any chemical preparation, and several Tang emperors are now believed to have died from mercury poisoning caused by drinking immortality elixirs prepared for them by court alchemists. The Taoist programme, as a programme for the prevention of death, was a complete failure. The accidental byproduct of that failed programme has since killed more human beings than essentially any other artefact ever produced by any civilisation in human history. The fire medicine, in the long historical record, has been used to do approximately the opposite of what its original inventors were trying to achieve.