The Nekrasov-Shatashvili limit for the low-energy behavior of N=2 and N=2* supersymmetric SU(2) gauge theories is encoded in the spectrum of the Mathieu and Lam'e equations, respectively. This correspondence is usually expressed via an all-orders Bohr-Sommerfeld relation, but this neglects non-perturbative effects, the nature of which is very different in the electric, magnetic and dyonic regions. In the gauge theory dyonic region the spectral expansions are divergent, and indeed are not Borel-summable, so they are more properly described by resurgent trans-series in which perturbative and non-perturbative effects are deeply entwined. In the gauge theory electric region the spectral expansions are convergent, but nevertheless there are non-perturbative effects due to poles in the expansion coefficients, and which we associate with worldline instantons. This provides a concrete analog of a phenomenon found recently by Drukker, Marino and Putrov in the large N expansion of the ABJM matrix model, in which non-perturbative effects are related to complex space-time instantons. In this paper we study how these very different regimes arise from an exact WKB analysis, and join smoothly through the magnetic region. This approach also leads to a simple proof of a resurgence relation found recently by Dunne and Unsal, showing that for these spectral systems all non-perturbative effects are subtly encoded in perturbation theory, and identifies this with the Picard-Fuchs equation for the quantized elliptic curve.