The mechanism regulating the equilibrium electrostatic potential in the scrape-off layer (SOL) of magnetic confinement devices is elucidated. Based on a generalized Ohm's law and the boundary conditions at the magnetic presheath entrance, an analytical expression for the equilibrium electrostatic potential is derived. Results imply that the relative importance of the plasma dynamics at the sheath and far away from the wall in setting the value of the electrostatic potential depends on the density and temperature drops that are established between the two regions. Global, three-dimensional fluid simulations of tokamak SOL turbulence in a simple configuration are performed, confirming the validity of our predictions. The results presented here are general and can be applied to other open-field-line configurations, including linear devices and simple magnetized toroidal devices.