Humans in all societies form and participate in cooperative alliances. To successfully navigate an alliance-laced world, the human mind needs to detect new coalitions and alliances as they emerge, and predict which of many potential alliance categories are currently organizing an interaction. We propose that evolution has equipped the mind with cognitive machinery that is specialized for performing these functions: an alliance detection system. In this view, racial categories do not exist because skin color is perceptually salient; they are constructed and regulated by the alliance system in environments where race predicts social alliances and divisions. Early tests using adversarial alliances showed that the mind spontaneously detects which individuals are cooperating against a common enemy, implicitly assigning people to rival alliance categories based on patterns of cooperation and competition. But is social antagonism necessary to trigger the categorization of people by alliance—that is, do we cognitively link A and B into an alliance category only because they are jointly in conflict with C and D? We report new studies demonstrating that peaceful cooperation can trigger the detection of new coalitional alliances and make race fade in relevance. Alliances did not need to be marked by team colors or other perceptually salient cues. When race did not predict the ongoing alliance structure, behavioral cues about cooperative activities up-regulated categorization by coalition and down-regulated categorization by race, sometimes eliminating it. Alliance cues that sensitively regulated categorization by coalition and race had no effect on categorization by sex, eliminating many alternative explanations for the results. The results support the hypothesis that categorizing people by their race is a reversible product of a cognitive system specialized for detecting alliance categories and regulating their use. Common enemies are not necessary to erase important social boundaries; peaceful cooperation can have the same effect.