A capacitor stores electric charge between two conducting parallel plates separated by an insulating material called a dielectric. When a switch is closed to connect the capacitor to a power supply, electrons are repelled from the negative plate and attracted to the positive plate, building up opposite charges on each plate. This stored charge results in an electric field within the dielectric and a potential difference between the plates. The capacitor can then maintain this stored charge even after the switch is opened, until the capacitor is discharged.