We provide evidence on the mechanisms linking resource-related income shocks to con- flict, focusing specifically on illegal crops. We hypothesize that the degree of group compe- tition over resources and the extent of law enforcement explain whether opportunity cost or contest effects dominate. Combining temporal variation in international drug prices with spa- tial variation in the suitability to produce opium, we show that in Afghanistan higher prices increase household living standards, and reduce conflict. Using georeferenced data on the drug production network and Taliban versus pro-government control highlights the importance of opportunity cost effects, and reveals heterogeneous effects in line with our theory.