This paper examines the effects of gunfights between drug gangs in Rio de Janeiro's favelas on student achievement. We explore variation in violence that occurs across time and space when gangs battle over territories. Within-school estimates indicate that students' scores are lower in math in years in which they are exposed to drug battles. The effect increases with conflict intensity, duration, and proximity to exam dates and decreases with the distance between the school and the conflict location. School supply is an important mechanism. Gunfights are associated with higher teacher absenteeism, principal turnover, and temporary school closings.