Collective behaviour is common in bacteria, plants, and animals, and thus across ecosystems, from biofilms to cities. With collective behaviour, social interactions among individuals propagate to affect the behaviour of groups, while group-level responses in turn affect individual behaviour. These cross-scale feedbacks between individuals, populations and their environments can provide fitness benefits, such as efficient exploitation of uncertain resources as well as costs, such as increased resource competition. While the social mechanics of collective behaviour are increasingly well-studied, its ecological significance remains poorly understood. Here we introduce collective movement into a model of consumer-resource dynamics to demonstrate that collective behaviour can attenuate consumer-resource cycles and promote species coexistence. We focus on collective movement as a particularly well-understood example of collective behaviour. Adding collective movement to canonical unstable ecological scenarios causes emergent social-ecological feedback which mitigates conditions that would otherwise result in extinction. Collective behaviour could play a key role in the maintenance of biodiversity.