We provide new evidence about the mechanisms linking resource-related income shocks to conflict. To do so, we combine temporal variation in international drug prices with new data on spatial variation in opium suitability to examine the effect of opium profitability on conflict in Afghanistan. District level results indicate a conflict-reducing effect over the 2002-2014 period, both in a reducedform setting and with three different instrumental variables. We provide evidence for two main mechanisms. First, the importance of contest effects depends on the degree of violent group competition over valuable resources. By using data on the drug production process, ethnic homelands, and Taliban versus pro-government influence, we show that on average group competition for suitable districts is relatively low in Afghanistan. Second, we highlight the role of opportunity costs by showing that opium profitability positively affects household living standards, and becomes more important after a sudden rise in unemployment due to the dissolution of large armed militias after an exogenous policy change.