  We give conditions for the existence of regular optimal partitions, with an
arbitrary number $\ell\geq 2$ of components, for the Yamabe equation on a
closed Riemannian manifold $(M,g)$.
  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 solution with nontrivial components if $\dim M\geq 10$, $(M,g)$ is not
locally conformally flat and satisfies an additional geometric assumption
whenever $\dim M=10$. Moreover, we show that the limit profiles of the
components of the solution separate spatially as the competition parameter goes
to $-\infty$, giving rise to an optimal partition. We show that this partition
exhausts the whole manifold, and we prove the regularity of both the interfaces
and the limit profiles, together with a free boundary condition.
  For $\ell=2$ the optimal partition obtained yields a least energy
sign-changing solution to the Yamabe equation with precisely two nodal domains.
