Military spending was the main government expenditure until the 20th century, and it still represents a significant fraction of most governments’ budgets. We develop a theoretical model to understand how both military and trade alliances with military leaders can impact defense spending. By increasing the costs of military aggression by a non-ally, an alliance reduces the probability of war and allows minor partners reducing their military spending in exchange for a stronger trade relationship with an alliance leader and a higher trading surplus for the latter. We test our hypotheses with data on 138 countries for 1996–2020. Our results show that the importance of the trade relationship and the trade balance with the military alliance leader is a significant driver of military spending. The greater the weight of trade with the military leader and the higher its trade surplus, the lower is the defense spending of the minor partner.