We show that global properties of gauge groups can be understood as geometric properties in M-theory. Different wrappings of a system of N M5-branes on a torus reduce to four-dimensional theories with AN−1 gauge algebra and different unitary groups. The classical properties of the wrappings determine the global properties of the gauge theories without the need to impose any quantum conditions. We count the inequivalent wrappings as they fall into orbits of the modular group of the torus, which correspond to the S-duality orbits of the gauge theories.