The restoration of the resting potential in neurons or muscle fibres following the passage of a nerve impulse. Repolarization is brought about by diffusion of potassium ions out of the neuron and by active elimination of sodium ions (see sodium pump).