Gunpowder was, according to prevailing academic consensus, invented in the 9th century in China, and the earliest record of a written formula for gunpowder appears in the 11th century Song Dynasty text, Wujing Zongyao. This discovery led to the invention of fireworks and the earliest gunpowder weapons in China. In the centuries following the Chinese discovery, gunpowder weapons began appearing in the Muslim world, Europe, and India. The technology spread from China through the Middle East or Central Asia, and then into Europe. The earliest Western accounts of gunpowder appear in texts written by English philosopher Roger Bacon in the 13th century.
Now watch this guy make gunpowder in less than 4 minutes!
Gray Matter: Easy DIY Gunpowder