The geometric Langlands program can be described in a natural way by compactifying on a Riemann surface C a twisted version of N = 4 super Yang-Mills theory in four dimensions. The key ingredients are electric-magnetic duality of gauge theory, mirror symmetry of sigma-models, branes, Wilson and 't Hooft operators, and topological field theory. Seemingly esoteric notions of the geometric Langlands program, such as Hecke eigensheaves and D-modules, arise naturally from the physics.