Extensive research suggests that electoral competition and power alternations increase violence in weakly institutionalized democracies. Yet, little is known about how political parties affect violence and security. We theorize that the type of party strengthened in elections shapes security outcomes and argue that the rise of programmatic parties, at the expense of clientelistic parties, can significantly reduce violence. In contexts of large-scale criminal violence, programmatic parties are less likely to establish alliances with coercive actors because they possess fewer incentives and greater coordination capacity. Focusing on Brazil, we use a regression discontinuity design that leverages the as-if random assignment of election winners across three rounds of mayoral races. We find that violent crime decreased in municipalities where programmatic parties won coin-flip elections, while it increased in those where clientelistic parties triumphed. Our findings suggest that whether electoral competition increases violence depends on the type of party that wins elections.