Coral reefs world-wide are threatened by escalating local and global impacts, and some impacted reefs have shifted from coral dominance to a state dominated by macroalgae. Therefore, there is a growing need to understand the processes that affect the capacity of these ecosystems to return to coral dominance following disturbances, including those that prevent the establishment of persistent stands of macroalgae. Unlike many reefs in the Caribbean, over the last several decades, reefs around the Indo-Pacific island of Moorea, French Polynesia have consistently returned to coral dominance following major perturbations without shifting to a macroalgae-dominated state. Here, we present evidence of a rapid increase in populations of herbivorous fishes following the most recent perturbation, and show that grazing by these herbivores has prevented the establishment of macroalgae following near complete loss of coral on offshore reefs. Importantly, we found the positive response of herbivorous fishes to increased benthic primary productivity associated with coral loss was driven largely by parrotfishes that initially recruit to stable nursery habitat within the lagoons before moving to offshore reefs later in life. These results underscore the importance of connectivity between the lagoon and offshore reefs for preventing the establishment of macroalgae following disturbances, and indicate that protecting nearshore nursery habitat of herbivorous fishes is critical for maintaining reef resilience.