We study the causal impact of patent invalidation on subsequent innovation and exit by patent holders. The analysis uses patent litigation data from the US Federal Circuit Court and exploits random allocation of judges to control for endogeneity of the decision. Invalidation causes patent holders to reduce patenting over a five-year window by 50% on average, but the effect is heterogeneous. The impact is large for small- and medium-sized firms, particularly where they face many large competitors, and for patents central to their research portfolio. We find no significant effect for large firms. Invalidation also increases exit from patenting by small firms.