Mutualistic networks are formed when the interactions between two classes of species are mutually beneficial. They are important examples of cooperation shaped by evolution. Mutualism between animals and plants plays a key role in the organization of ecological communities 1-3 . Such networks in ecology have generically evolved a nested architecture 4,5 independent of species composition and latitude 6,7 -specialists interact with proper subsets of the nodes with whom generalists interact 1 . Despite sustained efforts 5,8,9,10 to explain observed network structure on the basis of community-level stability or persistence, such correlative studies have reached minimal consensus 11,12,13 . Here we demonstrate that nested interaction networks could emerge as a consequence of an optimization principle aimed at maximizing the species abundance in mutualistic communities. Using analytical and numerical approaches, we show that because of the mutualistic interactions, an increase in abundance of a given species results in a corresponding increase in the total number of individuals in the community, as also the nestedness of the interaction matrix. Indeed, the species abundances and the nestedness of the interaction matrix are correlated by an amount that depends on the strength of the mutualistic interactions. Nestedness and the observed spontaneous emergence of generalist and specialist species occur for several dynamical implementations of the variational principle under stationary conditions. Optimized networks, while remaining stable, tend to be less resilient than their counterparts with randomly assigned interactions. In particular, we analytically show that the abundance of the rarest species is directly linked to the resilience of the community. Our work provides a unifying framework for studying the emergent structural and dynamical properties of ecological mutualistic networks 2,5,10,14 .Statistical analyses of empirical mutualistic networks indicate that a hierarchical nested structure is prevalent and is characterized by nestedness values that are consistently higher than those found in randomly assembled networks with the same number of species and interactions 1,6 . Nevertheless, the degree of nestedness varies among networks. Recently 5,10 , it has been argued that nestedness increases biodiversity and begets stability, but these results are in conflict with robust theoretical evidences showing that ecological communities with nested interactions are inherently less stable than unstructured ones 12,14,15 and that mutualism could be detrimental to persistence 11,15 . We aim to elucidate general optimization mechanisms underlying network structure and its influence on community dynamics and stability.There is a venerable history of the use of variational principles for understanding nature, which has led to significant advances in many sub--fields of physics, including classical mechanics, electromagnetism, relativity, and quantum mechanics. Our goal is to determine the appropriate variational principle tha...