Typically, fire comes from a chemical reaction between oxygen in the atmosphere and some sort of fuel (wood or gasoline, for example). Of course, wood and gasoline don't spontaneously catch on fire just because they're surrounded by oxygen. For the combustion reaction to happen, you have to heat the fuel to its ignition temperature.
Here's the sequence of events in a typical wood fire:
Something heats the wood to a very high temperature. The heat can come from lots of different things -- a match, focused light, friction, lightning, something else that is already burning...
When the wood reaches about 300 degrees Fahrenheit (150 degrees Celsius), the heat decomposes some of the cellulose material that makes up the wood.
Some of the decomposed material becomes volatile and is released as gases. We know these gases as smoke. Smoke is compounds of hydrogen, carbon and oxygen. The rest of the material forms char, which is nearly pure carbon, and ash, which is all of the unburnable minerals in the wood (calcium, potassium, and so on). The char is what you buy when you buy charcoal. Charcoal is wood that has been heated to remove nearly all of the volatile gases and leave behind the carbon. That is why a charcoal fire burns with no smoke.
The actual burning of wood then happens in two separate reactions:
- When the volatile gases are hot enough (about 500 degrees F (260 degrees C) for wood), the compound molecules break apart, and the atoms recombine with the oxygen to form water, carbon dioxide and other products. In other words, they burn.
- The carbon in the char combines with oxygen as well, and this is a much slower reaction. That is why charcoal in a BBQ can stay hot for a long time.
A side effect of these chemical reactions is a lot of heat. The fact that the chemical reactions in a fire generate a lot of new heat is what sustains the fire. Many fuels burn in one step. Gasoline is a good example. Heat vaporizes gasoline and it all burns as a volatile gas. There is no char. Humans have also learned how to meter out the fuel and control a fire. A candle is a tool for slowly vaporizing and burning wax.
As they heat up, the rising carbon atoms (as well as atoms of other material) emit light. This "heat produces light" effect is called incandescence, and it is the same kind of thing that creates light in a light bulb. It is what causes the visible flame. Flame color varies depending on what you're burning and how hot it is. Color variation within in a flame is caused by uneven temperature. Typically, the hottest part of a flame -- the base -- glows blue, and the cooler parts at the top glow orange or yellow.
In addition to emitting light, the rising carbon particles may collect on surrounding surfaces as soot.
The dangerous thing about the chemical reactions in fire is the fact that they are self-perpetuating. The heat of the flame itself keeps the fuel at the ignition temperature, so it continues to burn as long as there is fuel and oxygen around it. The flame heats any surrounding fuel so it releases gases as well. When the flame ignites the gases, the fire spreads.
On Earth, gravity determines how the flame burns. All the hot gases in the flame are much hotter (and less dense) than the surrounding air, so they move upward toward lower pressure. This is why fire typically spreads upward, and it's also why flames are always "pointed" at the top. If you were to light a fire in a microgravity environment, say onboard the space shuttle, it would form a sphere!