Competition plays an ambiguous role in nursing home markets where public and private payers coexist. Using U.S. nursing home data with a wide range of market structures, we find a U-shaped relationship between competition and service quality when nursing homes serve a mix of public and private segments, and a monotonically increasing relationship when nursing homes mostly serve the public, price-regulated, segment. The outcomes can be explained by the interplay of two opposing effects of competition: the reputation-building effect, whereby competing firms choose high quality to build a good reputation, and the rent-extraction effect, whereby competition hinders investment for quality improvements by lowering price premia. These observations are consistent with a repeated game model that incorporates public and private-payer segments. This paper was accepted by Stefan Scholtes, healthcare management.