Observations from cultured cells 1-3, animal models4 and patients5-7raise the possibility that the dependency of tumours on the therapeutic drugs to which they have acquired resistance represents a vulnerability with potential applications in cancer treatment. However, for this drug addiction trait to become of clinical interest, we must first define the mechanism that underlies it. We performed an unbiased CRISPR-Cas9 knockout screen on melanoma cells that were both resistant and addicted to inhibition of the serine/ threonine-protein kinase BRAF, in order to functionally mine their genome for 'addiction genes'. Here we describe a signalling pathway comprising ERK2 kinase and JUNB and FRA1 transcription factors, disruption of which allowed addicted tumour cells to survive on treatment discontinuation. This occurred in both cultured cells and mice and was irrespective of the acquired drug resistance mechanism. In melanoma and lung cancer cells, death induced by drug withdrawal was preceded by a specific ERK2-dependent phenotype switch, alongside transcriptional reprogramming reminiscent of the epithelial-mesenchymal transition. In melanoma cells, this reprogramming caused the shutdown of microphthalmia-associated transcription factor (MITF), a lineage survival oncoprotein; restoring this protein reversed phenotype switching and prevented the lethality associated with drug addiction. In patients with melanoma that had progressed during treatment with a BRAF inhibitor, treatment cessation was followed by increased expression of the receptor tyrosine kinase AXL, which is associated with the phenotype switch. Drug discontinuation synergized with the melanoma chemotherapeutic agent dacarbazine by further suppressing MITF and its prosurvival target, B-cell lymphoma 2 (BCL-2), and by inducing DNA damage in cancer cells. Our results uncover a pathway that underpins drug addiction in cancer cells, which may help to guide the use of alternating therapeutic strategies for enhanced clinical responses in drug-resistant cancers.