Patients with melanoma that progresses on ipilimumab and, if BRAF(V600) mutant-positive, a BRAF or MEK inhibitor or both, have few treatment options. We assessed the efficacy and safety of two pembrolizumab doses versus investigator-choice chemotherapy in patients with ipilimumab-refractory melanoma. We carried out a randomised phase 2 trial of patients aged 18 years or older from 73 hospitals, clinics, and academic medical centres in 12 countries who had confirmed progressive disease within 24 weeks after two or more ipilimumab doses and, if BRAF(V600) mutant-positive, previous treatment with a BRAF or MEK inhibitor or both. Patients had to have resolution of all ipilimumab-related adverse events to grade 0-1 and prednisone 10 mg/day or less for at least 2 weeks, an Eastern Cooperative Oncology Group (ECOG) performance status of 0 or 1, and at least one measurable lesion to be eligible. Using a centralised interactive voice response system, we randomly assigned (1:1:1) patients in a block size of six to receive intravenous pembrolizumab 2 mg/kg or 10 mg/kg every 3 weeks or investigator-choice chemotherapy (paclitaxel plus carboplatin, paclitaxel, carboplatin, dacarbazine, or oral temozolomide). Randomisation was stratified by ECOG performance status, lactate dehydrogenase concentration, and BRAF(V600) mutation status. Individual treatment assignment between pembrolizumab and chemotherapy was open label, but investigators and patients were masked to assignment of the dose of pembrolizumab. We present the primary endpoint at the prespecified second interim analysis of progression-free survival in the intention-to-treat population. This study is registered with ClinicalTrials.gov, number NCT01704287. The study is closed to enrolment but continues to follow up and treat patients. Between Nov 30, 2012, and Nov 13, 2013, we enrolled 540 patients: 180 patients were randomly assigned to receive pembrolizumab 2 mg/kg, 181 to receive pembrolizumab 10 mg/kg, and 179 to receive chemotherapy. Based on 410 progression-free survival events, progression-free survival was improved in patients assigned to pembrolizumab 2 mg/kg (HR 0·57, 95% CI 0·45-0·73; p<0·0001) and those assigned to pembrolizumab 10 mg/kg (0·50, 0·39-0·64; p<0·0001) compared with those assigned to chemotherapy. 6-month progression-free survival was 34% (95% CI 27-41) in the pembrolizumab 2 mg/kg group, 38% (31-45) in the 10 mg/kg group, and 16% (10-22) in the chemotherapy group. Treatment-related grade 3-4 adverse events occurred in 20 (11%) patients in the pembrolizumab 2 mg/kg group, 25 (14%) in the pembrolizumab 10 mg/kg group, and 45 (26%) in the chemotherapy group. The most common treatment-related grade 3-4 adverse event in the pembrolizumab groups was fatigue (two [1%] of 178 patients in the 2 mg/kg group and one [<1%] of 179 patients in the 10 mg/kg group, compared with eight [5%] of 171 in the chemotherapy group). Other treatment-related grade 3-4 adverse events include generalised oedema and myalgia (each in two [1%] patients) in those given pembrolizumab 2 mg/kg; hypopituitarism, colitis, diarrhoea, decreased appetite, hyponatremia, and pneumonitis (each in two [1%]) in those given pembrolizumab 10 mg/kg; and anaemia (nine [5%]), fatigue (eight [5%]), neutropenia (six [4%]), and leucopenia (six [4%]) in those assigned to chemotherapy. These findings establish pembrolizumab as a new standard of care for the treatment of ipilimumab-refractory melanoma. Merck Sharp & Dohme.