In the Sahel region, disputes between farmers and herders are often linked to religious, ethnic, and resource conflicts. Farmerâherder relations are put under pressure by negative out-group perceptions and affected by resource constraints, particularly those created by changes in climatic conditions. This study makes two key contributions: first, it examines the impact of in-group and out-group identities on farmerâherder relations under uncertainty; and second, it integrates qualitative and quantitative methods. In this study, a public good experiment was conducted with 332 farmers and herders in Senegal comparing in-group and out-group identity priming effects under individual and collective risks. The experiment was paired with 14 in-depth focus group discussions (FGDs) to elicit key mechanisms for in-group and out-group cooperation. The results show that priming out-group membership reduces cooperation towards out-group members, especially among farmers. Interestingly, herders reduced cooperation in response to in-group primes, likely attributable to rivalry between local and mobile herders. FGDs revealed that negative perceptions of mobile herders (transhumant pastoralists) drive this behavior. Additionally, introducing collective risks, such as those resulting from climate change, worsens in-groupâout-group biases. The findings highlight the need to address negative stereotyping of mobile herders to prevent escalations of conflicts in relatively peaceful areas like Senegal, where farmers and herders regularly interact.