An alternator is a device in a vehicle's electrical system that generates electricity. It is responsible for charging the battery and powering the electrical components while the engine is running.