We present necessary and sufficient conditions for an operator of the type sum of squares to be globally hypoelliptic on $T \times G$, where T is a compact Riemannian manifold and G is a compact Lie group. These conditions involve the global hypoellipticity of a system of vector fields on G and are weaker than Hörmander’s condition, while generalizing the well known Diophantine conditions on the torus. Examples of operators satisfying these conditions in the general setting are provided.