This paper studies the causal impact of patents on subsequent innovation by the patent holder. The analysis is based on court invalidation of patents by the U.S. Court of Appeals for the Federal Circuit, and exploits the random allocation of judges to control for the endogeneity of the judicial decision. Patent invalidation leads to a 50 percent decrease in patenting by the patent holder, on average, but the impact depends critically on characteristics of the patentee and the competitive environment. The effect is entirely driven by small innovative firms in technology fields where they face many large incumbents. Invalidation of patents held by large firms does not change the intensity of their innovation but shifts the technological direction of their subsequent patenting.