Background: There are few effective treatment options for patients with recurrent or metastatic head-and-neck squamous cell carcinoma. Pembrolizumab showed antitumour activity and manageable toxicity in early-phase trials. We aimed to compare the efficacy and safety of pembrolizumab versus standard-of-care therapy for the treatment of head-and-neck squamous cell carcinoma. Methods: We did a randomised, open-label, phase 3 study at 97 medical centres in 20 countries. Patients with head-and-neck squamous cell carcinoma that progressed during or after platinum-containing treatment for recurrent or metastatic disease (or both), or whose disease recurred or progressed within 3–6 months of previous multimodal therapy containing platinum for locally advanced disease, were randomly assigned (1:1) in blocks of four per stratum with an interactive voice-response and integrated web-response system to receive pembrolizumab 200 mg every 3 weeks intravenously or investigator's choice of standard doses of methotrexate, docetaxel, or cetuximab intravenously (standard-of-care group). The primary endpoint was overall survival in the intention-to-treat population. Safety was analysed in the as-treated population. This trial is registered with ClinicalTrials.gov, number NCT02252042, and is no longer enrolling patients. Findings: Between Dec 24, 2014, and May 13, 2016, 247 patients were randomly allocated to pembrolizumab and 248 were randomly allocated to standard of care. As of May 15, 2017, 181 (73%) of 247 patients in the pembrolizumab group and 207 (83%) of 248 patients in the standard-of-care group had died. Median overall survival in the intention-to-treat population was 8·4 months (95% CI 6·4–9·4) with pembrolizumab and 6·9 months (5·9–8·0) with standard of care (hazard ratio 0·80, 0·65–0·98; nominal p=0·0161). Fewer patients treated with pembrolizumab than with standard of care had grade 3 or worse treatment-related adverse events (33 [13%] of 246 vs 85 [36%] of 234). The most common treatment-related adverse event was hypothyroidism with pembrolizumab (in 33 [13%] patients) and fatigue with standard of care (in 43 [18%]). Treatment-related death occurred in four patients treated with pembrolizumab (unspecified cause, large intestine perforation, malignant neoplasm progression, and Stevens-Johnson syndrome) and two patients treated with standard of care (malignant neoplasm progression and pneumonia). Interpretation: The clinically meaningful prolongation of overall survival and favourable safety profile of pembrolizumab in patients with recurrent or metastatic head and neck squamous cell carcinoma support the further evaluation of pembrolizumab as a monotherapy and as part of combination therapy in earlier stages of disease. Funding: Merck Sharp & Dohme, a subsidiary of Merck & Co.