Rupture of endosomes and lysosomes is a major cellular stress condition leading to cell death and degeneration. Here, we identified an essential role for the ubiquitin-directed AAA-ATPase, p97, in the clearance of damaged lysosomes by autophagy. Upon damage, p97 translocates to lysosomes and there cooperates with a distinct set of cofactors including UBXD1, PLAA, and the deubiquitinating enzyme YOD1, which we term ELDR components for Endo-Lysosomal Damage Response. Together, they act downstream of K63-linked ubiquitination and p62 recruitment, and selectively remove K48-linked ubiquitin conjugates from a subpopulation of damaged lysosomes to promote autophagosome formation. Lysosomal clearance is also compromised in MEFs harboring a p97 mutation that causes inclusion body myopathy and neurodegeneration, and damaged lysosomes accumulate in affected patient tissue carrying the mutation. Moreover, we show that p97 helps clear late endosomes/lysosomes ruptured by endocytosed tau fibrils. Thus, our data reveal an important mechanism of how p97 maintains lysosomal homeostasis, and implicate the pathway as a modulator of degenerative diseases.