We show that the partition function of free Maxwell theory on a generi
c eulidean four-manifold transforms in a non-trivial way under electri
c-magnetic duality. The classical part of the partition sum can be map
ped onto the genus-one partition function of a 2D toroidal model, with
out the oscillator contributions. This map relates electric-magnetic d
uality to modular invariance of the toroidal model and, conversely, th
e O(d, d', Z) duality to the invariance of Maxwell theory under the 4D
mapping class group. The dualities and the relation between toroidal
models and Maxwell theory can be understood by regarding both theories
as dimensional reductions of a self-dual 2-form theory in sia dimensi
ons. Generalizations to more U(1)-gauge fields and reductions from hig
her dimensions are also discussed. We find indications that the abelia
n gauge theories with N=4 space-time supersymmetry are exactly duality
invariant.