The multilevel society of hamadryas baboons, consisting of troops, bands, clans, and one-male units (OMUs), is commonly perceived to be an effective means of adapting to variable food availability while allowing spatial cohesion in response to predator pressure. The relationship between these variables, however, has never been tested quantitatively. The Filoha site in Awash National Park, Ethiopia is ideally suited to such an investigation as it contains nutrient-dense palm forests in addition to the Acacia scrublands typical of hamadryas distribution elsewhere, allowing comparisons of spatial cohesion across habitat types. Here, we use observations over a 1-year period to examine the relationship between resource availability, perceived predator pressure, and spatial cohesion in a band of wild hamadryas baboons at Filoha. Our results demonstrate that the band was more likely to break into OMUs when foraging in habitats with lower food availability, and that the band fissioned into independent clans more often when preferred resources were not available. Furthermore, the baboons remained in larger aggregations for longer periods of time (i.e., prior to embarking on their daily foraging route) on mornings after predators were heard in the vicinity, and increased cohesion in response to encounters with people who may have been perceived as predators. These results support the notion that hamadryas baboons change their social groupings in response to both food availability and predation risk and that the ability of hamadryas bands to cleave and coalesce in response to changes in these factors underlies the evolution of the hamadryas modular social structure. Am J Phys Anthropol 2012. © 2012 Wiley Periodicals, Inc.