The energy in petrol originally came from the Sun. Explain how it got into petrol.

Fossil fuels are obtained from remains of animals and plants under the earth over a period of millions of years these existed and grew due to sun's energy thus the ultimate source of fossil fuels can be considered to be the sun's energy.