Importance: Effective treatment options are limited for patients with advanced, metastatic esophageal cancer progressing after 2 or more lines of systemic therapy. Objective: To evaluate the efficacy and safety of pembrolizumab for patients with advanced, metastatic esophageal squamous cell carcinoma (ESCC) or advanced, metastatic adenocarcinoma of the esophagus and gastroesophageal junction that progressed after 2 or more lines of systemic therapy. Design, Setting, and Participants: This phase 2, open-label, interventional, single-arm study, KEYNOTE-180, enrolled 121 patients from January 12, 2016, to March 21, 2017, from 57 sites in 10 countries. Patients had advanced, metastatic esophageal cancer that progressed after 2 or more lines of therapy and had evaluable tumor samples for biomarkers. Interventions: Pembrolizumab, 200 mg, was administered intravenously every 3 weeks until disease progression, unacceptable toxic effects, or study withdrawal, for up to 2 years. Main Outcomes and Measures: Primary end point was objective response rate per the Response Evaluation Criteria in Solid Tumors by central imaging review for all patients. Results: As of September 18, 2017, of 121 enrolled patients (100 men and 21 women; median age, 65 years [range, 33-87 years]), 18 (14.9%) had undergone 3 or more prior therapies, 63 (52.1%) had ESCC, and 58 (47.9%) had tumors positive for programmed death ligand-1 (PD-L1), defined as a combined positive score of 10 or higher assessed by immunohistochemistry. Median duration of follow-up was 5.8 months (range, 0.2-18.3 months). Objective response rate was 9.9% (95% CI, 5.2%-16.7%) among all patients (12 of 121), and median duration of response was not reached (range, 1.9-14.4 months). Objective response rate was 14.3% (95% CI, 6.7%-25.4%) among patients with ESCC (9 of 63), 5.2% (95% CI, 1.1%-14.4%) among patients with adenocarcinoma (3 of 58), 13.8% (95% CI, 6.1%-25.4%) among patients with PD-L1-positive tumors (8 of 58), and 6.3% (95% CI, 1.8%-15.5%) among patients with PD-L1-negative tumors (4 of 63). Overall, 15 patients (12.4%) had treatment-related grade 3 to 5 adverse events. Only 5 patients (4.1%) discontinued treatment because of adverse events. There was 1 treatment-related death from pneumonitis. Conclusions and Relevance: Where effective treatment options are an unmet need, pembrolizumab provided durable antitumor activity with manageable safety in patients with heavily pretreated esophageal cancer. Phase 3 studies evaluating pembrolizumab vs standard therapy for patients with esophageal cancer progressing after first-line therapy or in combination with chemotherapy as first-line therapy for patients with locally advanced unresectable or metastatic esophageal cancer are ongoing.