Checkpoint blockade therapy targeting the programmed-death ligand 1 (PD-L1) and its receptor programmed cell death 1 promotes T-cell-mediated immunosurveillance against tumours, and has been associated with marked clinical benefit in cancer patients. Antibodies against PD-L1 function by blocking PD-L1 on the cell surface, but intracellular storage of PD-L1 and its active redistribution to the cell membrane can minimize the therapeutic benefits, which highlights the importance of targeting PD-L1 throughout the whole cell. Here, we show that PD-L1 is palmitoylated in its cytoplasmic domain, and that this lipid modification stabilizes PD-L1 by blocking its ubiquitination, consequently suppressing PD-L1 degradation by lysosomes. We identified palmitoyltransferase ZDHHC3 (DHHC3) as the main acetyltransferase required for the palmitoylation of PD-L1, and show that the inhibition of PD-L1 palmitoylation via 2-bromopalmitate, or the silencing of DHHC3, activates antitumour immunity in vitro and in mice bearing MC38 tumour cells. We also designed a competitive inhibitor of PD-L1 palmitoylation that decreases PD-L1 expression in tumour cells to enhance T-cell immunity against the tumours. These findings suggest new strategies for overcoming PD-L1-mediated immune evasion in cancer.