A flywheel is a mechanical device that uses the conservation of angular momentum to store rotational energy, a form of kinetic energy proportional to the product of its moment of inertia and the square of its rotational speed.
It can be thought of as a kind of "mechanical battery," but it stores energy in the form of movement (kinetic energy, in other words) rather than the energy stored in the chemical form inside a traditional electrical battery.
Instead of wide and heavy steel wheels with even heavier steel rims, 21st-century flywheels tend to be more compact and made from carbon-fiber or composite materials, sometimes with steel rims, which work out perhaps a quarter as heavy.
In automobile engines, the flywheel serves to smooth out the pulses of energy provided by the combustion in the cylinders and to provide energy for the compression stroke of the pistons. The larger the rotational inertia of the flywheel, the smaller the changes in speed resulting from the intermittent power supply and demand.