Signal transducer and activator of transcription 3 (STAT3) has a critical role in regulating cell fate, inflammation and immunity1,2. Cytokines and growth factors activate STAT3 through kinase-mediated tyrosine phosphorylation and dimerization3,4. It remains unknown whether other factors promote STAT3 activation through different mechanisms. Here we show that STAT3 is post-translationally S-palmitoylated at the SRC homology 2 (SH2) domain, which promotes the dimerization and transcriptional activation of STAT3. Fatty acids can directly activate STAT3 by enhancing its palmitoylation, in synergy with cytokine stimulation. We further identified ZDHHC19 as a palmitoyl acyltransferase that regulates STAT3. Cytokine stimulation increases STAT3 palmitoylation by promoting the association between ZDHHC19 and STAT3, which is mediated by the SH3 domain of GRB2. Silencing ZDHHC19 blocks STAT3 palmitoylation and dimerization, and impairs the cytokine- and fatty-acid-induced activation of STAT3. ZDHHC19 is frequently amplified in multiple human cancers, including in 39% of lung squamous cell carcinomas. High levels of ZDHHC19 correlate with high levels of nuclear STAT3 in patient samples. In addition, knockout of ZDHHC19 in lung squamous cell carcinoma cells significantly blocks STAT3 activity, and inhibits the fatty-acid-induced formation of tumour spheres as well as tumorigenesis induced by high-fat diets in an in vivo mouse model. Our studies reveal that fatty-acid- and ZDHHC19-mediated palmitoylation are signals that regulate STAT3, which provides evidence linking the deregulation of palmitoylation to inflammation and cancer.