Empirical evidence suggests that there is substantial cross-firm variation in tax avoidance. However, this variation is not well understood. This paper provides a theoretical background for testing, and thus explaining, cross-firm differences in tax avoidance. We develop a formal model with two agents to analyze the incentives that lead firms to engage in tax avoidance. The tax avoidance decision is a function of moral hazard, tax-planning costs, and the potential to increase earnings. If the potential to increase earnings is low, the tax-planning decision is determined by moral hazard problems. In contrast, when this potential is high, the tax-planning decision is mainly driven by tax-planning costs, such as reputational and political costs. One implication of our model is that moral hazard can (partly) explain why some firms do not engage in tax avoidance: Severe problems of moral hazard make tax avoidance less likely. Our model can be a basis for testing differences in tax avoidance between different types of firms.