The chemical energy stored in the fuel (gasoline or diesel) is released through combustion (burning). This combustion produces heat energy, which then expands gases in the engine's cylinders. The expansion of these gases pushes pistons, converting the heat energy into mechanical energy that rotates the crankshaft. This rotational mechanical energy is then used to power the wheels of the car via the transmission and drivetrain. There are also smaller transformations involved, like some mechanical energy being lost to heat due to friction.