  Metapopulation models have been instrumental in demonstrating the ecological
impact of landscape structure on the survival of a focal species in complex
environments. However, extensions to multiple species with arbitrary dispersal
networks often rely on phenomenological assumptions limiting their scope. Here,
we develop a multilayer network model of competitive dispersing metacommunities
to investigate how spatially structured environments impact species coexistence
and ecosystem stability. We show that homogeneous environments always lead to
monodominance unless all species' fitness parameters are in an exact trade-off.
However, this precise fine-tuning does not guarantee coexistence in generic
heterogeneous environments. By introducing general spatial disorder in the
model, we solve it exactly in the mean-field limit, finding that stable
coexistence becomes possible in the presence of strong disorder. Crucially,
coexistence is supported by the spontaneous localization of species through the
emergence of ecological niches. Our results remain qualitatively valid in
arbitrary dispersal networks, where topological features can improve species
coexistence. Finally, we employ our model to study how correlated disorder
promotes spatial ecological patterns in realistic terrestrial and riverine
landscapes. Our work provides a novel framework to understand how landscape
structure enables coexistence in metacommunities by acting as the substrate for
ecological interactions.
