We use network analysis and mathematical modeling to understand and quantify the structure, dynamics, and function of biological communities, including their responses to environmental changes such as species extinctions, invasions, climate change, and fisheries. We focus on the biological mechanisms empirical research has shown to be important for the population dynamics and interactions of species. We integrate those mechanisms into mathematical models of ecological networks that we interrogate using computers, mathematical analysis and biological intuition, and whose predictions we test with empirical data. This research program has contributed a more mechanistic understanding of the structure and dynamics of ecological networks, a better integration between theoretical and empirical research in network ecology, and a more predictive theory to evaluate the responses of entire biological communities to environmental change.