Gunpowder is the first explosive to have been developed. Popularly listed as one of the "Four Great Inventions" of China, it was invented during the late Tang dynasty (9th century) while the earliest recorded chemical formula for gunpowder dates to the Song dynasty (11th century). Knowledge of gunpowder spread rapidly throughout Asia and Europe, possibly as a result of the Mongol conquests during the 13th century, with written formulas for it appearing in the Middle East between 1240 and 1280 in a treatise by Hasan al-Rammah, and in Europe by 1267 in the  by Roger Bacon. It was employed in warfare to some effect from at least the 10th century in weapons such as fire arrows, bombs, and the fire lance before the appearance of the gun in the 13th century. While the fire lance was eventually supplanted by the gun, other gunpowder weapons such as rockets and fire arrows continued to see use in China, Korea, India, and this eventually led to its use in the Middle East, Europe, and Africa. Bombs too never ceased to develop and continued to progress into the modern day as grenades, mines, and other explosive implements. Gunpowder has also been used for non-military purposes such as fireworks for entertainment, or in explosives for mining and tunneling.
The evolution of guns led to the development of large artillery pieces, popularly known as bombards, during the 15th century, pioneered by states such as the Duchy of Burgundy. Firearms came to dominate early modern warfare in Europe by the 17th century. The gradual improvement of cannons firing heavier rounds for a greater impact against fortifications led to the invention of the star fort and the bastion in the Western world, where traditional city walls and castles were no longer suitable for defense. The use of gunpowder technology also spread throughout the Islamic world and to India, Korea, and Japan. The so-called Gunpowder Empires of the early modern period consisted of the Mughal Empire, Safavid Empire, and Ottoman Empire.
The use of gunpowder in warfare during the course of the 19th century diminished due to the invention of smokeless powder. Gunpowder is often referred to today as "black powder" to distinguish it from the propellant used in contemporary firearms.