Tang Dynasty (618-906 CE)
It is thought to have been invented, possibly accidentally in the course of alchemical research, in the eighth or ninth century CE. Records of it appear in texts (e.g. "Zhenyuan miaodao yaolüe") in those centuries, and a chemical formula is recorded in the 11th century.