The main theories of biodiversity either neglect species interactions or assume that species interact randomly with each other. However, recent empirical work has revealed that ecological networks are highly structured, and the lack of a theory that takes into account the structure of interactions precludes further assessment of the implications of such network patterns for biodiversity. Here we use a combination of analytical and empirical approaches to quantify the influence of network architecture on the number of coexisting species. As a case study we consider mutualistic networks between plants and their animal pollinators or seed dispersers. These networks have been found to be highly nested, with the more specialist species interacting only with proper subsets of the species that interact with the more generalist. We show that nestedness reduces effective interspecific competition and enhances the number of coexisting species. Furthermore, we show that a nested network will naturally emerge if new species are more likely to enter the community where they have minimal competitive load. Nested networks seem to occur in many biological and social contexts, suggesting that our results are relevant in a wide range of fields.