  Let $M$ be a compact real-analytic manifold, equipped with a real-analytic
Riemannian metric $g,$ and let $\beta$ be a closed real-analytic 2-form on $M$,
interpreted as a magnetic field. Consider the Hamiltonian flow on $T^*M$ that
describes a charged particle moving in the magnetic field $\beta$. Following an
idea of T. Thiemann, we construct a complex structure on a tube inside $T^*M$
by pushing forward the vertical polarization by the Hamiltonian flow "evaluated
at time $i$." This complex structure fits together with $\omega-\pi^*\beta$ to
give a Kaehler structure on a tube inside $T^*M$. We describe this magnetic
complex structure in terms of its $(1,0)$-tangent bundle, at the level of
holomorphic functions, and via a construction using the embeddings of
Whitney-Bruhat and Grauert, which is a magnetic analogue to the analytic
continuation of the geometric exponential map. We describe an antiholomorphic
intertwiner between this complex structure and the complex structure induced by
$-\beta$, and we give two formulas for local Kaehler potentials, which depend
on a local choice of vector potential 1-form for $\beta$. When $\beta=0$, our
magnetic complex structure is the adapted complex structure of
Lempert-Sz\H{o}ke and Guillemin-Stenzel.
  We compute the magnetic complex structure explicitly for constant magnetic
fields on $\mathbb{R}^{2}$ and $S^{2}.$ In the $\mathbb{R}^{2}$ case, the
magnetic adapted complex structure for a constant magnetic field is related to
work of Kr\"otz-Thangavelu-Xu on heat kernel analysis on the Heisenberg group.
