An alternator is an electrical generator that converts mechanical energy into electrical energy in the form of alternating current. It is responsible for charging the battery and powering the electrical system of the vehicle while the engine is running.