Peripheral nociceptive neurons encode and convey injury-inducing stimuli toward the central nervous system. In normal conditions, tight control of nociceptive resting potential prevents their spontaneous activation. However, in many pathological conditions the control of membrane potential is disrupted, leading to ectopic, stimulus-unrelated firing of nociceptive neurons, which is correlated to spontaneous pain. We have investigated the role of KV7/M channels in stabilizing membrane potential and impeding spontaneous firing of nociceptive neurons. These channels generate low voltage-activating, noninactivating M-type K+ currents (M-current, IM), which control neuronal excitability. Using perforated-patch recordings from cultured, rat nociceptor-like dorsal root ganglion neurons, we show that inhibition of M-current leads to depolarization of nociceptive neurons and generation of repetitive firing. To assess to what extent the M-current, acting at the nociceptive terminals, is able to stabilize terminals' membrane potential, thus preventing their ectopic activation, in normal and pathological conditions, we built a multi-compartment computational model of a pseudo-unipolar unmyelinated nociceptive neuron with a realistic terminal tree. The modeled terminal tree was based on the in vivo structure of nociceptive peripheral terminal, which we assessed by in vivo multiphoton imaging of GFP-expressing nociceptive neuronal terminals innervating mice hind paw. By modifying the conductance of the KV7/M channels at the modeled terminal tree (terminal gKV7/M) we have found that 40% of the terminal gKV7/M conductance is sufficient to prevent spontaneous firing, while ~75% of terminal gKV7/M is sufficient to inhibit stimulus induced activation of nociceptive neurons. Moreover, we showed that terminal M-current reduces susceptibility of nociceptive neurons to a small fluctuations of membrane potentials. Furthermore, we simulated how the interaction between terminal persistent sodium current and M-current affects the excitability of the neurons. We demonstrated that terminal M-current in nociceptive neurons impeded spontaneous firing even when terminal Na(V)1.9 channels conductance was substantially increased. On the other hand, when terminal gKV7/M was decreased, nociceptive neurons fire spontaneously after slight increase in terminal Na(V)1.9 conductance. Our results emphasize the pivotal role of M-current in stabilizing membrane potential and hereby in controlling nociceptive spontaneous firing, in normal and pathological conditions.