For centuries Balinese rice farmers have been engaged in cooperative agricultural practices. Without centralized control, farmers have created a carefully coordinated system that allows productive farming in an ecosystem that is rife with water scarcity and the threat of disease and pests. We develop a simple game-theoretic model, inspired by a generation of careful anthropological field work, to provide a compact explanation for many of the most salient features observed in the system. We find that while externalities caused by either water scarcity or pests would, in isolation, be expected to cause a serious failure in the system, the ecology of the rice farming system links these two externalities in such a way that cooperation, rather than chaos, results. We test key features of the model through both natural and computational experiments and a field survey focused on the strategic motivations of the farmers. University of Arizona, Dept. of Anthropology, Tucson, AZ 85721, email: jlansing@u.Arizona.edu. Carnegie Mellon University, Social and Decision Sciences, Pittsburgh, PA 15213, and the Santa Fe Institute, 1399 Hyde Park Road, Santa Fe, NM 87501, email: email@example.com. Miller’s work was supported by core funding from the Santa Fe Institute.