Like an internal combustion engine of a car, a generator’s engine needs fuel to operate. Diesel, natural gas, propane, gasoline and biofuels are common options.
The combustion of the fuel is used to create a rotational movement in a crankshaft in the following way: Air is taken into a cylinder through an intake valve as the piston lowers. The piston then travels upward, causing the air to compress in the cylinder. When the air is compressed and reaches a certain temperature due to that compression, fuel is injected into the cylinder and ignites. The combustion, a small explosion, pushes the piston back down. The piston then returns to the top of the cylinder, pushing the gases from the combustion out the exhaust valve. The pistons are attached to a crankshaft, so as the pistons move up and down, it makes the crankshaft turn.
In a vehicle, this motion and energy would be used to propel the vehicle. In a generator, it is used for electricity generation.