The micronutrient selenium is incorporated via the selenocysteine biosynthesis pathway into the rare amino acid selenocysteine, which is required in selenoproteins such as glutathione peroxidases and thioredoxin reductases1,2. Here, we show that selenophosphate synthetase 2 (SEPHS2), an enzyme in the selenocysteine biosynthesis pathway, is essential for survival of cancer, but not normal, cells. SEPHS2 is required in cancer cells to detoxify selenide, an intermediate that is formed during selenocysteine biosynthesis. Breast and other cancer cells are selenophilic, owing to a secondary function of the cystine/glutamate antiporter SLC7A11 that promotes selenium uptake and selenocysteine biosynthesis, which, by allowing production of selenoproteins such as GPX4, protects cells against ferroptosis. However, this activity also becomes a liability for cancer cells because selenide is poisonous and must be processed by SEPHS2. Accordingly, we find that SEPHS2 protein levels are elevated in samples from people with breast cancer, and that loss of SEPHS2 impairs growth of orthotopic mammary-tumour xenografts in mice. Collectively, our results identify a vulnerability of cancer cells and define the role of selenium metabolism in cancer.