Fossil fuels such as petroleum formed from the remains of ancient plants and animals that lived hundreds of millions of years ago. When these organisms died, their remains were buried underground over time by layers of sediment. Through the application of heat, pressure, and microbial activity, the buried organic matter was converted into petroleum and other fossil fuels over millions of years.