According to current theory, anti-predator benefits promote group formation in open-dwelling ungulates. An inverse relationship between vigilance effort and group size has been documented frequently and thought to reflect the consequent decrease in perceived predation risk as group size increases. In contrast, competition costs are supposed to set the upper limit to the number of individuals that can forage together. As anti-predator behavior is no longer functional in the absence of predation and competition costs might be affected by resource distribution, the net benefit of aggregation will depend on the particular combination of predation risk and habitat structure experienced by the individual. To test this hypothesis, group-size effects on female time allocation and within-group aggression rate were compared between two guanaco populations exposed to contrasting levels of puma predation. Habitat structure within both sites consisted of mosaics of shrublands and grasslands, and group-size effects were also compared between these habitat types. Females under predation risk showed a strong reduction in vigilance as the number of adults in the group increased, whereas females from the predator-free population showed overall low levels of vigilance, regardless of group size. These results emphasize the anti-predator significance of the group-size effect on female vigilance, as well as guanaco plasticity to adjust time allocation to local conditions. On the other hand, within-group aggression rate increased with the number of adults in the group. Aggression rate was almost null within groups located in grasslands but was significantly higher in shrublands, regardless of predation risk, suggesting that the more heterogeneous distribution of shrubs increases the interference competition level. These results strengthen the notion of predation pressure and habitat structure as major determinants of the balance between costs and benefits of group living, and highlight the potential of individual behavioral patterns to make qualitative predictions about group-size variation within territorial ungulates.