A lithium-ion battery operates by shuttling lithium ions between the anode and cathode through an electrolyte. During discharge, lithium ions move from the anode to the cathode, releasing energy. During charging, an external power source drives the ions back to the anode, storing energy for future use.