When do strong national identities promote conflictual foreign policy attitudes, and when do they promote international cooperation? The conventional wisdom states that nationalism drives hawkish foreign policy preferences, warning e.g., of the dangers brought by contemporary “hypernationalism,” but this conclusion rests on the assumption that national identities are of the same kind. Moreover, claims about the relationship between nationalism and militarism tend to be causal, but the data used to test them are primarily observational. In this paper, I present a novel theory to argue that national identities have qualitatively different content, and that what nationalism means shapes how it affects foreign policy public opinion. National identities can be constituted by community norms, where members share a common history or values and maintaining the group’s unity requires a binary separation between “us” and “them,” or by equality, where constitutive norms reinforce fairness, reciprocity, and peer-like interactions within flexible boundaries. The results of a novel survey experiment with a nationally representative sample of the American public show that nationalism predicts militarism only when community shapes what it means to be an American. The opposite holds for equality-based identities: strong identifiers promote international cooperation, not conflict. I test the stability of these results across general militant and cooperative orientations and specific foreign policy issues -- including potential great power conflicts with China and Russia, the existing fight against ISIS, and cooperation over climate change, human rights, and international trade. Finally, the paper addresses how my theory and empirical strategy can improve research on the relationship between national/transnational identities and foreign policy attitudes in a cross-national context.