At rest, the potential difference between the inside and outside of the neuron is around -70mV. The sodium potassium pump is continually pumping 3 Na+ ions out for every 2 K+ ions it pumps in, and this maintains the resting potential of -70mV.
During an action potential a few sodium ion channels open, and Na+ diffuses into the neuron, decreasing the value of the potential difference. If and when the potential difference reaches the threshold potential of -50mV voltage-gated sodium ion channels open and the neurone is depolarised reaching a maximum potential difference of +40mV.
At this point the sodium ion channels close and potassium ion channels open allowing K+ ions to diffuse out of the neuron which is repolarised to -70mV. Generally this target is overshot (hyperpolarisation) to about -90mV, but the sodium-potassium pump corrects this.