The Chinese invented black powder which later transmitted to the Middle East, Africa, and Europe. The direct ancestor of the firearm is something called 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 fire lance was a black-powder–filled tube and was sometimes placed in the barrel so that it would fly out together with the flames. The first evidence of fire-lances appeared in China in the year 950.
The fire lance appeared in 10th century China during the Jin-Song Wars. It is often considered to be a proto-gun which is the predecessor of the hand cannon, and the ancestor of all firearms. Fire lances were relatively short range weapons and were used to give their user an advantage in close quarters combat.
The first fire lances consisted of a tube, usually bamboo, containing gunpowder and a slow match, strapped to a spear or other pole arm weapon. Soon 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. Then the the shrapnel came to be replaced by projectiles whose size and shape filled the barrel more closely. Thus, 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. Metal fire lance barrels appeared around the mid 13th century and these began to be used independently of the lance itself.
The independent metal barrel was known as an ‘eruptor’ and became the forerunner of the hand cannon.