Electrons heated in a local resonance zone of a magnetic well created either by a linear mirror or a finite aspect ratio torus are considered. If the heating has sufficient strength to drive a significant nonisotropy in the electron distribution function, an electrostatic potential variation along a field line is developed to maintain charge neutrality. The buildup of this space varying potential for times shorter than ion-transit times is determined analytically, and a limit to the number of electrons within the well that can be heated is found. The subsequent evolution of the potential on ion-transit and collision time scales is also determined. The theory is applied both to large mirror ratio devices characteristic of magnetic mirror confinement and to small mirror ratio devices characteristic of tokamaks. In the former configuration the theory is compared to experimental observations of potential buildup and decay in the multiple-mirror experiment (MMX) device [Phys. Fluids 29, 1208 (1986)] and shown to be consistent with the experiments. In the latter configuration, using the expected parameters of the Microwave Tokamak Experiment (MTX) [Proceedings of the 14th Annual Conference on Plasma Physics (Pergamon, New York, in press)], it is found that ΔΦ∼0.3Te is built up on the hot-electron-transit time scale, dropping to about 0.2Te on the ion-transit time scale, and then decaying further on a collisional time scale. Here Te is the electron temperature before heating. The potential has both poloidal and toroidal variation. Possible consequences include enhanced neoclassical transport and ion heating, and parametric excitation of low-frequency modes.