Under what conditions can democracy reduce violent conflict? We argue that, in weakly institutionalized contexts, institutional reforms that promote the rise of programmatic parties may decrease levels of violence. We exploit the implementation of a political reform in Brazil that gradually introduced electronic voting to reduce electoral fraud. Using a regression discontinuity design, we show that violence decreased by a half standard deviation in municipalities where electronic voting was first adopted, relative to those where the technology was not implemented. We show that by reducing electoral fraud and increasing enfranchisement, electronic voting eroded the power of hegemonic political machines more likely to collude with organized criminal groups. These results, we show, cannot be explained by higher investments in security or social programs. This paper sheds light on the links between criminal violence and elections, the alternatives to iron-fist policies to curb crime, and the unintended consequences of democratic reforms in weakly institutionalized contexts.