Background: Immune-related genes (IRGs) were linked to the prognosis of head and neck squamous cell carcinoma (HNSCC). This study aimed to identify the effects of an immune-related gene signature (IRGS) that can predict the of HNSCC prognosis. Methods: The expression data of 770 HNSCC patients from the TCGA database and the GEO database were used. To explore a predictive model, the Cox proportional hazards model was applied. The Kaplan-Meier survival analysis, as well as univariate and multivariate analyses were performed to evaluate the independent predictive value of IRGS. To explore biological functions of IRGS, enrichment analyses and pathway annotation for differentially expressed genes (DEGs) in different immune groups were applied, as well as the immune infiltration. Results: A prognostic signature comprising 27 IRGs was generated. IRGS significantly stratified HNSCC patients into high and low immune risk groups in regard to overall survival in the training cohort (HR = 3.69, 95% CI 2.73-4.98, P < 0.001). Likewise, IRGS could be linked to the prognosis of HNSCC in patients of the validation cohort (HR = 1.84, 95% CI 1.21-2.81, P < 0.01). Even after adjusting for TNM stage, IRGS was maintained as an independent predictor in the multivariate analysis (HR = 3.62, 95% CI 2.58-5.09, P < 0.001), and in the validation cohort (HR = 1.73, 95% CI 1.12-2.67, P = 0.014). The IFN-α response, the IFN-γ response, IL-2/STAT5 signaling, and IL-6/JAK/STAT3 signaling were all negatively correlated with the immune risk (P < 0.01). Immune infiltration of the high-risk group was significantly lower than that of the low-risk group (P < 0.01). Most notably, the infiltration of CD8 T cells, memory-activated CD4 T cells, and regulatory T cells was strongly upregulated in the low immune risk groups, while memory resting CD4 T cell infiltration was downregulated (P < 0.01). Conclusion: Our analysis provides a comprehensive prognosis of the immune microenvironments and outcomes for different individuals. Further studies are needed to evaluate the clinical application of this signature.