Armed clientelism is a particular form of patronage in which politicians and non-state armed groups establish a symbiotic relationship where the former provides economic resources, judicial protection, or other benefits, while the latter provides political support and votes. In this paper a theory of armed clientelism is presented, which shows that when politicians establish illegal alliances with armed groups and mafias, they face a political tradeoff: illegal alliances augment the probability of being elected, but generate the risk of being removed from office. The model predicts that in a context in which a mafia controls a district or a town, armed clientelism is more likely when social diversity among the constituency is high, the judicial system is inefficient, party identification of citizens to clientelistic parties is low, and candidates are highly budget-constrained. It also shows that armed clientelism is more likely when the illegal group and the machine are ideologically aligned.