The behaviour of an animal is determined by metabolic, emotional and social factors1,2. Depending on its state, an animal will focus on avoiding threats, foraging for food or on social interactions, and will display the appropriate behavioural repertoire3. Moreover, survival and reproduction depend on the ability of an animal to adapt to changes in the environment by prioritizing the appropriate state4. Although these states are thought to be associated with particular functional configurations of large-brain systems5,6, the underlying principles are poorly understood. Here we use deep-brain calcium imaging of mice engaged in spatial or social exploration to investigate how these processes are represented at the neuronal population level in the basolateral amygdala, which is a region of the brain that integrates emotional, social and metabolic information. We demonstrate that the basolateral amygdala encodes engagement in exploratory behaviour by means of two large, functionally anticorrelated ensembles that exhibit slow dynamics. We found that spatial and social exploration were encoded by orthogonal pairs of ensembles with stable and hierarchical allocation of neurons according to the saliency of the stimulus. These findings reveal that the basolateral amygdala acts as a low-dimensional, but context-dependent, hierarchical classifier that encodes state-dependent behavioural repertoires. This computational function may have a fundamental role in the regulation of internal states in health and disease.