Antibodies targeting the programmed cell death protein-1 (PD-1) molecule have been reported to hold promising antitumor activities in patients with nasopharyngeal carcinoma (NPC). However, only a small subset of NPC patients benefits from the anti-PD-1 monotherapy and factors that affect the treatment response need further investigation. This study aimed to examine the impact of multiple genetic and environmental factors on outcome of anti-PD-1 immunotherapy by identifying tumor size, tumor mutation burden (TMB) based on whole exon sequencing, human leukocyte antigen class I (HLA-I) homo-/heterozygosity and supertypes, blood Epstein-Barr virus (EBV) DNA load, T cell proportions, and interferon-γ(IFN-γ) levels in a cohort of 57 NPC patients that received Nivolumab or Camrelizumab treatment. Moreover, we profiled the longitudinal changes in gut microbiota composition using shotgun metagenomics sequencing. We observed that high TMB combined with HLA-I heterozygosity was associated with improved clinical outcomes. In agreement with previous studies, we found that patients with higher plasma EBV DNA load showed worse progression-free survival. We found no evidence for an effect of gut bacterial diversity on the treatment response, but identified a higher abundance of seven specific gut bacteria at baseline of non-responders, including Blautia wexlera and Blautia obeum, as well as four other bacteria belonging to the Clostridiales order, and one Erysipelatoclostridium. Combined, this study provides insight into the influence of several genetic and environmental factors on anti-PD-1 immunotherapy responses in NPC patients.