After the Chinese invented black powder during the 9th century, these inventions were later transmitted to the Middle East, Africa, and Europe. The direct ancestor of the firearm is the fire lance. The prototype of the fire lance was invented in China during the 10th century and is the predecessor of all firearms.
The direct ancestor of the firearm is the fire lance, a black-powder–filled tube attached to the end of a spear and used as a flamethrower (not to be confused with the Byzantine flamethrower); shrapnel was sometimes placed in the barrel so that it would fly out together with the flames. The earliest known depiction of a gunpowder weapon is the illustration of a fire-lance on a mid-10th century silk banner from Dunhuang. The De'an Shoucheng Lu, an account of the siege of De'an in 1132 during the Jin–Song Wars, records that Song forces used fire-lances against the Jurchen.
The proportion of saltpeter in the propellant was increased to maximize its explosive power. To better withstand that explosive power, the paper, and bamboo of which fire-lance barrels were originally made came to be replaced with metal. And to take full advantage of that power, the shrapnel came to be replaced by projectiles whose size and shape filled the barrel more closely. With this, the three basic features of the gun emerged: a barrel made of metal, high-nitrate gunpowder, and a projectile which totally occludes the muzzle so that the powder charge exerts its full potential in propellant effect.
The earliest depiction of a gun is a sculpture from a cave in Sichuan dating to the 12th century of a Chinese figure carrying a vase-shaped bombard with flames and a cannonball coming out of it. The oldest surviving firearm is the Heilongjiang hand cannon dated to 1288, which was discovered at a site in modern-day Acheng District where the History of Yuan records that battles were fought at that time; Li Ting, a military commander of Jurchen descent, led footsoldiers armed with guns in battle to suppress the rebellion of the Christian Mongol Prince Nayan.