During elecrolysis, an electric current is passed through an electrolyte. Positive ions are attracted to the cathode, there they gain electrons and are discharged as elements. Negative ions are attracted to the anode, where they lose electrons and are discharged as elements.