We study the optimal transition from fossil fuels to renewable energy in a neoclassical growth economy with endogenous technological progress in energy production from fossil fuels and renewable energy sources. Innovations keep fossil energy cost under control even as increased exploitation raises mining costs. Nevertheless, the economy eventually transitions to renewable energy. Learning-by-doing in renewable energy production implies that it is optimal to transition to renewable energy before the cost of fossil fuels reaches parity with renewable energy costs. Since energy costs escalate as the transition approaches, growth of consumption and output decline sharply around the transition. The energy shadow price remains more than double current values for over 75 years around the switch time, resulting in a continued drag on output and consumption growth. The model highlights the important role that energy can play in influencing economic growth.