Before an action potential can even start, it is important to remember that there are already uneven concentrations of ions over the membrane. Potassium ions are at a higher concentration inside the cell, while sodium ions are at a higher concentration outside the cell. The membrane is also more permeable to potassium ions than to sodium ions; so potassium ions move down their concentration gradient to leave the cell at a greater rate than sodium ions enter the cell, and this leads to a potential difference being set up across the membrane of about -70mV. Because the membrane is more permeable to potassium ions, this is closer to the equilibrium potential for potassium, though it is influenced by the presence of sodium ions and other anions.
An action potential begins when voltage gated sodium ion channels, known as Na(V) channels open. This leads to an influx of sodium ions (moving down their concentration gradient), and the cell membrane begins to depolarise. This leads to the opening of more Na(V) channels, so the membrane depolarises even further. This continues until all of the available Na(V) channels are open, and the action potential reaches a peak of about +40mV. The more positive potential difference then causes the channels to deactivate, so that no more sodium can enter the cell. As the polarity of the cell membrane reverses, voltage-gated potassium channels also open, leading to an outward flow of potassium ions. These stay open even as the Na(V) channels inactivate, so that the membrane potential becomes more negative again, and in fact "overshoots" the resting potential of -70mV to around -90mV. This point in time is known as the refractory period, when action potentials can no longer fire. The resting potential is restored by the sodium-potassium pump, which continuously pumps out three sodium ions for every 2 potassium ions.