Background: Although it has been reported by several studies that using AI to predict the prognosis of nasopharyngeal carcinoma (NPC) based on magnetic resonance (MR) image, the information around the tumor was not valued and the post-treatment MR images were ignored. Herein we aimed to predict the prognosis of advanced NPC (stage Ⅲ-Ⅳa) using pre- and post-treatment MR images based on deep learning (DL).Methods: A total of 206 patients with primary NPC who were diagnosed and treated at the Renmin Hospital of Wuhan University between June 2012 and January 2018 were retrospectively selected. A rectangular region of interest (ROI), which included the tumor area, surrounding tissues and organs, was delineated on each pre- and post-treatment MR image. Two InceptionResnetV2-based transfer learning models, named pre-model and post-model, were trained with the Pre-dataset and the Post-dataset, respectively. In addition, an ensemble learning model based on the pre-model and post-models was trained. The three established models were evaluated by receiver operating characteristic (ROC) analysis, confusion matrix, and Harrell’s concordance indices (C-index) after the model test. High-risk-related heat maps were developed according to the DL models.Results: The pre-model, post-model, and ensemble models displayed a C-index of 0.717 (95% CI: 0.639 to 0.795), 0.811 (95% CI: 0.745–0.877), 0.830 (95% CI: 0.767–0.893), and AUC of 0.745 (95% CI: 0.592–0.897), 0.820 (95% CI: 0.687–0.953), and 0.841 (95% CI: 0.715–0.968) for the test cohort, respectively. In comparison with the models, the post-model performance was better than the pre-model, which indicated the importance of post-treatment images for prognosis prediction. All three DL models performed better than the TNM staging system. The captured features presented on heat maps showed that the areas around the tumor and lymph nodes were related to the prognosis of the tumor.Conclusions: The three established DL models based on pre- and post-treatment MR images have a better performance than TNM staging. Post-treatment MR images are of great significance for prognosis prediction and could contribute to clinical decision-making.