The earliest documentation of fireworks dates back to 7th century China (time of the Tang Dynasty), where they were invented. The fireworks were used to accompany many festivities. It is thus a part of the culture of China and had its origin there; eventually it spread to other cultures and societies. The art and science of firework making has developed into an independent profession. In China, pyrotechnicians were respected for their knowledge of complex techniques in mounting firework displays. Chinese people originally believed that the fireworks could expel evil spirits and bring about luck and happiness.
During the Song Dynasty (960–1279), many of the common people could purchase various kinds of fireworks from market vendors, and grand displays of fireworks were also known to be held. In 1110, a large fireworks display in a martial demonstration was held to entertain Emperor Huizong of Song (r. 1100–1125) and his court. A record from 1264 states that a rocket-propelled firework went off near the Empress Dowager Gong Sheng and startled her during a feast held in her honor by her son Emperor Lizong of Song (r. 1224–1264). Rocket propulsion was common in warfare, as evidenced by the Huolongjing compiled by Liu Bowen (1311–1375) and Jiao Yu (fl. c. 1350–1412). In 1240 the Arabs acquired knowledge of gunpowder and its uses from China. A Syrian named Hasan al-Rammah wrote of rockets, fireworks, and other incendiaries, using terms that suggested he derived his knowledge from Chinese sources, such as his references to fireworks as "Chinese flowers".