Lead was added to gasoline as a antiknock agent, which prevents engine knocking (also called detonation) that can damage the engine. However, lead is highly toxic and its use in gasoline was phased out in many countries due to its harmful effects on human health and the environment.
The phasing out of leaded gasoline was a major environmental victory, significantly reducing lead levels in the atmosphere and improving air quality. Today, most cars use unleaded gasoline, which uses alternative antiknock agents like ethanol or MTBE.