Inclusion Criteria:
* Has a diagnosis of HCC by radiological criteria and/or pathological confirmation.
* Has an eligibility scan (CT of the chest, triphasic CT scan or MRI of the abdomen, and CT or MRI of the pelvis) confirming complete radiological response ≥4 weeks after complete surgical resection or local ablation. Randomization needs to occur within 12 weeks of the date of surgical resection or local ablation.
* Has no radiologic evidence of disease prior to enrollment.
* Has an Eastern Cooperative Oncology Group (ECOG) performance status of 0 or 1 within 7 days prior to Cycle 1, Day 1.
* Has a Child-Pugh class A liver score (5 to 6 points) within 7 days prior to Cycle 1, Day 1.
* Has alpha fetoprotein (AFP) concentration lower than 400 ng/mL within 28 days prior to Cycle 1, Day 1.
* Has controlled hepatitis B (Hep B).
* Has recovered adequately from toxicity and/or complications from the local intervention (surgical resection or local ablation) prior to starting study treatment.
* If female, is not pregnant or breastfeeding, and at least one of the following conditions applies: 1) Is not a woman of childbearing potential (WOCBP); or 2) Is a WOCBP and using a contraceptive method that is highly effective or be abstinent from heterosexual intercourse as their preferred and usual lifestyle (a WOCBP must have a negative pregnancy test within 72 hours before the first dose of study treatment).
* If undergoing surgical resection, has submitted a tumor tissue sample during Screening.
* Has adequate organ function.
Exclusion Criteria:
* Has a known additional malignancy that is progressing or has required active antineoplastic treatment (including hormonal) or surgery within the past 3 years.
* Has had esophageal or gastric variceal bleeding within the last 6 months.
* Has clinically apparent ascites on physical examination.
* Has had clinically diagnosed hepatic encephalopathy in the last 6 months.
* Has received local therapy to liver ablation other than with radiofrequency or microwave ablation.
* Has a history of (noninfectious) pneumonitis/interstitial lung disease that required steroids or has current pneumonitis/interstitial lung disease.
* Has an active infection requiring systemic therapy.
* Has dual active Hepatitis B Virus (HBV) and Hepatitis C Virus (HCV) infection at study entry.
* Has a known history of human immunodeficiency virus (HIV) infection.
* Has known active tuberculosis (TB; Bacillus tuberculosis).
* Has received prior therapy with an anti-PD-1, anti-PD-L1, or anti PD-L2 agent or with an agent directed to another stimulatory or co-inhibitory T-cell receptor (eg, CTLA-4, OX-40, CD137).
* Has received prior systemic anti-cancer therapy for HCC including investigational agents.
* Is receiving any of the following prohibited concomitant therapies:1) Antineoplastic systemic chemotherapy or biological therapy; 2) Immunotherapy not specified in this protocol; 3) Investigational agents other than pembrolizumab; 4) Radiation therapy; 5) Oncological surgical therapy; or systemic glucocorticoids for any purpose other than to modulate symptoms from an AE that is suspected to have an immunologic etiology.
* Has received a live vaccine within 30 days prior to the first dose of study treatment.
* Is currently participating in or has participated in a study of an investigational agent or has used an investigational device within 4 weeks prior to Cycle 1, Day 1.
* Has a diagnosis of immunodeficiency or is receiving chronic systemic steroid therapy or any other form of immunosuppressive therapy within 7 days prior to Cycle 1, Day 1.
* Has severe hypersensitivity (≥Grade 3) to pembrolizumab and/or any of its excipients.
* Has an active autoimmune disease that has required systemic treatment in past 2 years.
* Has a known psychiatric or substance abuse disorder that would interfere with the participant's ability to cooperate with the requirements of the study.
* Has had an allogenic tissue/solid organ transplant.