Using both numerical simulations and analytical methods, we investigate how the stability of ecological communities depends on the number of species they contain. To investigate complex communities, we construct communities from modular “subcommunities” that can have arbitrary community structure; e.g. subcommunities could consist of pairs of predator and prey species, trios of prey, specialist predator and generalist predator, or any collection of interacting species. By building entire communities from subcommunities, we can change the number of species in the community without changing community structure. We further suppose that species sharing the same ecological role in different subcommunities act additively on the per capita population growth rates of other species. Under these assumptions, the inter-actions between species from different subcommunities have no effect on community-level stability, measured by the variability in the combined densities of species sharing the same ecological role in different subcommunities. Furthermore, increasing species richness (i.e. the number of subcommunities comprising the community) increases community-level stability only when it introduces species that respond differently to environmental fluctuations. Therefore, our results support the “insurance hypothesis” that species richness increases community-level stability by insuring that some species in a community are tolerant of different environmental fluctuations.