HowStuffWorks explains that gunpowder functions through a chemical reaction between the combination of sulfur, charcoal and an oxidizer, usually either saltpeter or niter. The saltpeter acts as an oxidizer, and the sulfur and charcoal combine together to act as fuel. Also commonly referred to as "black powder," gunpowder can be used as both a propellant, as in both guns and fireworks, and as an explosive.
According to HowStuffWorks, gunpowder was first made in the 9th century by Chinese alchemists, who mixed charcoal, sulfur and saltpeter together. Ground together, the ingredients formed a powder that was referred to as "serpentine." The mixture was often combined with a liquid, commonly water or wine, and then pushed through a screen to form small pellets. Gunpowder was first used by the Chinese for fireworks, bombs and grenades. The mixture was introduced to Europe in the 13th century and found its way into firearms in the 14th century. For centuries, it was the only practical explosive known, and it was used in a wide variety of mining applications. The safety fuse was introduced in 1831 and made the use of gunpowder in mining far safer. By the late 19th century, gunpowder had mostly fallen out of use, and it was replaced by smokeless powders in firearms and by dynamite in mining applications.