Hybrid density-functional theory has been used to study phase stability and defect formation in the CuGaS2 chalcopyrite. The equilibrium population of intrinsic defects is predicted and it is shown that the material is intrinsically p-type doped. Extrinsic defects consisting of elements from group II, group IV, and group VII of the periodic table are studied. It is predicted that n-type doping of CuGaS2 is not possible through the addition of these extrinsic defects. The stability of the ordered defect compounds CuGa3S5 and CuGa5S8 is also investigated. These compounds are shown to be stable only in a very narrow region of phase space.