We study the moduli spaces of flat SL(r)- and PGL(r)-connections, or equivalently, Higgs bundles, on an algebraic curve. These spaces are noncompact Calabi-Yau orbifolds; we show that they can be regarded as mirror partners in two different senses. First, they satisfy the requirements laid down by Strominger-Yau-Zaslow (SYZ), in a suitably general sense involving a B-field or flat unitary gerbe. To show this, we use their hyperkahler structures and Hitchin's integrable systems. Second, their Hodge numbers, again in a suitably general sense, are equal. These spaces provide significant evidence in support of SYZ. Moreover, they throw a bridge from mirror symmetry to the duality theory of Lie groups and, more broadly, to the geometric Langlands program.