This study aimed to develop a model using Epstein–Barr virus (EBV)-associated hub genes in order to predict the prognosis of nasopharyngeal carcinoma (NPC). Differential expression analysis, univariate regression analysis, and machine learning were performed in three microarray datasets (GSE2371, GSE12452, and GSE102349) collected from the GEO database. Three hundred and sixty-six EBV-DEGs were identified, 25 of which were found to be significantly associated with NPC prognosis. These 25 genes were used to classify NPC into two subtypes, and six genes (C16orf54, CD27, CD53, CRIP1, RARRES3, and TBC1D10C) were found to be hub genes in NPC related to immune infiltration and cell cycle regulation. It was shown that these genes could be used to predict the prognosis of NPC, with functions related to tumor proliferation and immune infiltration, making them potential therapeutic targets. The findings of this study could aid in the development of screening and prognostic methods for NPC based on EBV-related features.