We analyze the relation between religious beliefs, religious participation, and social cooperation. We focus on religions that instill beliefs about the connection between rewards and punishments and social behavior. We show how religious organizations arise endogenously, and identify a "spiritual" as well as a "material" payoff for being religious. We show that religious groups that are more demanding in their rituals are smaller, more cohesive, and are composed of individuals with more "extreme" beliefs. We use our framework to analyze the response of beliefs and religious membership to correlated shocks in society, such as natural disasters or periods of prosperity. (JEL D12, D83, Z12, Z13)