The process by which an action potential is created, involving the movement of ions across the cell membrane.