  We count the connected components in the moduli space of PU(p,q)-representations of the fundamental group for a closed oriented surface. The components are labelled by pairs of integers which arise as topological invariants of the flat bundles associated to the representations. Our results show that for each allowed value of these invariants, which are bounded by a Milnor-Wood type inequality, there is a unique non-empty connected component. Interpreting the moduli space of representations as a moduli space of Higgs bundles, we take a Morse theoretic approach using a certain smooth proper function on the Higgs moduli space. A key step is the identification of the function's local minima as moduli spaces of holomorphic triples. We prove that these moduli spaces of triples are non-empty and irreducible. 
Representations of the fundamental group of a surface in PU(p,q) and   holomorphic triples