Gunpowder is s a mixture of sulfur, charcoal, and potassium nitrate (saltpeter) and it was the first chemical explosive. It burns, generates heat and a large volume of gas. Because of that, gunpowder has been widely used as a propellant in firearms and as a pyrotechnic composition in fireworks.
It was invented in the 9th century in China by alchemists who tried to find elixir of life, and the earliest record of a written formula for gunpowder appears in the 11th century Song Dynasty text - Wujing Zongyao. From it they made variety of weapons, including flamethrowers, rockets, bombs, and land mines. Fire arrows tipped with explosives were invented in 10th century while a fire lance or fire spear, a type of gunpowder-fueled flamethrower, was invented in 11th century. First cannon, a hand variant, was made in 13th century. Gunpowder was also used for fireworks, during celebrations and to scare away evil spirits.
Some sources say that Arabs gained knowledge of gunpowder from Chinese in 13th century, because they mention saltpeter as "Chinese snow", fireworks as "Chinese flowers" and rockets as "Chinese arrows". Those sources are written in 13th century but they attribute this ideas to “forefathers" and because of that, there are theories that, they knew about gunpowder even earlier. Genghis Khan used a Chinese specialist catapult unit during the battle of Transoxania in 1219. Another theory says that he brought gunpowder to central Asia. Some hand-held cannons were used by the Mamluks at the Battle of Ain Jalut in 1260.
There are two possible ways in which Europe was introduced to the gunpowder: by the Silk Road or during the Mongol invasion in the first half of 13th century. Chinese firearms and gunpowder weapons were used by the Mongols against European forces at the Battle of Mohi in 1241. Gunpowder is mentioned, for the first time in Europe, in 1267 and gun, as a picture in a manuscript by Walter de Milemete, in 1326. The first battle in Europe where cannons were used was the Battle of Crécy in 1346. Firearms were applied to the battle fields and by 1350 cannons were a common weapon as any other. Spanish empire, Ottoman empire, Portugal and in Japan used arquebus at first and muskets after that. In the 14th century European powder makers improved manufacturing of gunpowder by adding liquid. This reduced dust which in turn reduced the risk of explosion during manufacture. Resulting gunpowder was granulated into corn which was easier for loading into guns and more powerful. In time two European schools of pyrotechnic appeared: in Italy and in Germany.
Gunpowder was not only used in warfare but in mining and tunnel and canal construction. Hungarians used gunpowder, for the first time in the world, in their mines in 1627. German miners used it in Britain in 1638 after which its use becomes standard method. Canal du Midi in Southern France was a first time that gunpowder was used on a large scale in civil engineering. It linked the Mediterranean Sea with the Atlantic with 240 km of canal.