Fire is a chemical chain reaction which takes place with the evolution of heat and light. In order for a fire to take place there are 3 main ingredients that must be present: Oxygen, Heat and Fuel.
In chemistry we call the type of reaction that produces fire a combustion reaction. Combustion is a high-temperature exothermic (heat releasing) redox (oxygen adding) chemical reaction between a fuel and an oxidant, usually atmospheric oxygen, that produces oxidized, often gaseous products, in a mixture termed as smoke.
Whenever we complete a combustion reaction a hydrocarbon (compound of C and H) there are generally the same products formed: CO2 and H2O.
The fuel you burn in your car's engine contains octane, C8H18. When octane is burned, the products are CO2 and H2O.
2C8H18(l) + 25O2(g) → 16CO2(g) + 18H2O(g)
The key ingredient to the process is the availability of oxygen. Combustion cannot take place in an atmosphere devoid of oxygen.
So if you have a bottle of gasoline (octane) sitting around and open to the atmosphere which contains oxygen, why doesn’t it just burst into flames?
The answer to this question is the need to overcome the activation energy of the reaction, which means that it requires energy at first to "jump start" the process. In your car, the distributor and battery provide this starting energy by creating an electrical "spark". Other sources of initial energy can come from the Sun, matches, friction, etc.
The combustion reaction itself is quite exothermic.
When heat is produced in the process of a chemical reaction this is known as an Exothermic Reaction.
N2 + 3H2 → 2NH3 + Heat
C + O2 → CO2 + Heat
When heat is absorbed from the reacting substances this is known as an Endothermic Reaction.
2C + H2 - Heat → C2H2
3O2 - Heat → 2O3
But remember, whether endothermic or exothermic, both types of reactions still require an Activation Energy to begin.