Non-small cell lung cancer (NSCLC) patients harboring a KRAS mutation have unfavorable therapeutic outcomes with chemotherapies, and the mutation also renders tolerance to immunotherapies. There is an unmet need for a new strategy for overcoming immunosuppression in KRAS-mutant NSCLC. The recently discovered role of melatonin demonstrates a wide spectrum of anticancer impacts; however, the effect of melatonin on modulating tumor immunity is largely unknown. In the present study, melatonin treatment significantly reduced cell viability accompanied by inducing cell apoptosis in KRAS-mutant NSCLC cell lines including A549, H460, and LLC1 cells. Mechanistically, we found that lung cancer cells harboring the KRAS mutation exhibited a higher level of programmed death ligand 1 (PD-L1). However, treatment with melatonin substantially downregulated PD-L1 expressions in both the presence and absence of interferon (IFN)-γ stimulation. Moreover, KRAS-mutant lung cancer cells exhibited higher Yes-associated protein (YAP) and transcriptional coactivator with PDZ-binding motif (TAZ) levels, and PD-L1 expression was positively correlated with YAP and TAZ in lung cancer cells. Treatment with melatonin effectively suppressed YAP and TAZ, which was accompanied by downregulation of YAP/TAZ downstream gene expressions. The combination of melatonin and an inhibitor of YAP/TAZ robustly decreased YAP and PD-L1 expressions. Clinical analysis using public databases revealed that PD-L1 expression was positively correlated with YAP and TAZ in patients with lung cancer, and PD-L1 overexpression suggested poor survival probability. An animal study further revealed that administration of melatonin significantly inhibited tumor growth and modulated tumor immunity in a syngeneic mouse model. Together, our data revealed a novel antitumor mechanism of melatonin in modulating the immunosuppressive tumor microenvironment by suppressing the YAP/PD-L1 axis and suggest the therapeutic potential of melatonin for treating NSCLC.