Habitat loss caused by anthropogenic climate change poses a significant threat to global biodiversity, and behavioural change is often the first line of defence for affected organisms. However, the potential for altered behaviour to moderate the impact of resource loss remains untested. Using a six-year dataset from three reefs in Japan, we investigated the behavioural responses of 23 butterflyfish species to coral habitat loss and recovery. Aggressive behaviours decreased when resources were depleted, consistent with predictions from the economic defendability model. Once coral cover recovered, aggression returned to pre-disturbance levels, demonstrating behavioural flexibility potentially capable of preventing energetic deficits in the short-term. These results underscore the importance of behavioural plasticity in species survival during environmental disturbances and highlight potential ramifications for ecological dynamics at broader scales, such as species coexistence. Our results emphasise the need to understand and conserve behavioural adaptive capacities in the face of ongoing global change.