Do military alliances foster aggressive behavior in allies to the point of undermining the security goal of the alliance? Like others, we find that alliance commitments may cause moral hazard because allies do not fully internalize the costs of actions that can lead to war. But unlike others, we show that the effect of moral hazard can improve security. Moral hazard can be the driving force behind generating deterrence and avoiding costly conflict. Aggressors may refrain from initiating crises if their target enjoys additional resources from its ally and so is more willing to fight back. So rather than incurring costs, moral hazard may be the very key to deterring potential aggressors and minimizing the risk of conflict. This behavior allows alliance partners to capture a "deterrence surplus," which are the gains from avoiding conflict.