An extensive literature shows that agency issues and transactions costs influence vertical integration. Another mature literature indicates that market structure influences competitive behavior. However, less consideration has been given to how vertical integration and market structure may interact. I address this gap by focusing on the potential for moral hazard caused by intra-firm competition in retail gasoline markets. I argue that when multiple stations share a common brand in a market, a vertically separated station has an incentive to deviate from the cooperative strategy that the brand-owning refiner would prefer. I empirically test this prediction using rich data, and find evidence of such moral hazard. Moreover, I find that refiners behave in a way consistent with the desire to minimize it: They are more likely to employ vertically separated contracts in markets where the number of affiliated stations is small.