Resource scarcity has become an increasingly pressing challenge to the world. How scarcity affects people's preferences and behavior has been taken as an important issue for development. This study examines the impact of long-term exposure to resource scarcity on farmers’ cooperation. Specifically, we focus on water scarcity in irrigation agriculture, and examine the effect of water scarcity on cooperation in the context of a gravity irrigation system in western China. A historical irrigation water quota system provides an opportunity to measure exogenous variations of water scarcity within an otherwise homogeneous region. We use the ratio of the arable land area to the irrigation water quota of each village as our measure of water scarcity. Moreover, we use the contributions in a public goods game to measure the farmers’ willingness to cooperate. Combining a household survey and a lab-in-the-field experiment with 312 rural residents in northwestern China, we find that irrigation water scarcity significantly increases farmers’ willingness to cooperate. The results are robust to potential endogeneity concerns and many confounding factors. We also find that water scarcity is positively correlated with irrigation management activities and canal conditions. Our findings provide important policy implications for common pool resource management and collective actions in rural communities.