Fire is caused by a chemical reaction between two or more substances, typically oxygen in the air and some sort of fuel (gasoline, wood, or coal for example). This reaction is triggered by extreme heat, often caused by another flame or a spark. The fire's own heat is sufficient to keep the chemical reaction going as long as there is fuel to burn.
The basic idea of a flamethrower is to spread fire by launching burning fuel. The earliest flamethrowers, dating roughly from the 5th century B.C., were long tubes filled with burning solid material (such as sulfur or coal). These weapons worked in the same way as a blow-gun -- warriors just blew into one end of the tube, propelling the burning matter toward their enemies.
A more sophisticated sort of flamethrower came into widespread use in the 7th Century. In this era, the Byzantine Empire added "Greek fire" to its arsenal. Greek fire was probably a mixture of liquid petroleum, sulfur, quicklime and other elements. In any case, it was a highly-flammable, oil-based fluid.
In combat, Byzantine forces would pump this substance from a large reservoir, through narrow brass tubes. These tubes concentrated the pressurized liquid into a powerful stream, the same way a hose and nozzle concentrate water into a narrow jet. The soldiers lit a fuse at the end of the brass tubes to ignite the fluid stream as it shot out. The fluid stream carried fire dozens of feet through the air.
The Byzantines mounted these weapons along the walls of Constantinople, as well as the bows of their ships. Since the flammable substance was oil-based, it would still burn even when it hit the water, making it a particularly effective weapon in naval battles.
Initially, the Byzantines' enemies were mystified by this horrific weapon, but before long, others were copying the technology. The Chinese applied their advanced technology to take the idea to the next level. The Byzantines used a very basic pump, like the sort used to drive water out of an underground well. This kind of pump only pushes out fluid on the downstroke, so the Byzantine flamethrower could only shoot fire in short bursts. The Chinese had developed a more advanced pump, the double-acting bellows. Double-acting bellows consist of a pivoting pedal that drives two pumping chambers. When the pedal is pushing down on one chamber (the downstroke), it's lifting up on the other (the upstroke). In this way, the pump is constantly pushing out fluid, allowing a continuous stream of fuel (and therefore a constant blast of fire).
Soon after this sort of weaponry came into use, it was eclipsed by another pyrotechnic technology: gunpowder. Over the next thousand years, gunpowder revolutionized the world of warfare, and flamethrowers more or less fell by the wayside.
But as we'll see in the next section, flamethrowers were eventually reintroduced into the world's combat arsenal, in a modified form.