  We prove the existence of regular optimal $G$-invariant partitions, with an
arbitrary number $\ell\geq 2$ of components, for the Yamabe equation on a
closed Riemannian manifold $(M,g)$ when $G$ is a compact group of isometries of
$M$ with infinite orbits. To this aim, we study a weakly coupled competitive
elliptic system of $\ell$ equations, related to the Yamabe equation. We show
that this system has a least energy $G$-invariant solution with nontrivial
components and we show that the limit profiles of the its components separate
spatially as the competition parameter goes to $-\infty$, giving rise to an
optimal partition.
  For $\ell=2$ the optimal partition obtained yields a least energy
sign-changing $G$-invariant solution to the Yamabe equation with precisely two
nodal domains.
