Fossil fuels were formed hundreds of millions of years ago from the fossilized remains of plants and animals. After the organisms died and decomposed, they were eventually buried under hundreds or thousands of feet of mud, rock, and sand. Over time, pressure and heat from the earth compacted the material into layers of sedimentary rock. Different types of fossil fuels were formed based on the types of animals and plants that had decomposed, how long this material was buried, and the degree of temperature and pressure that existed.