The prediction of the chemical oxygen demand (COD) and total nitrogen (TN) in integrated anaerobic–anoxic–oxic (A2O) and anoxic–oxic (AO) processes (i.e., A2O+AO process) was achieved using a dynamic ensemble model that reflects the dynamics of wastewater treatment plants (WWTPs). This model effectively captures the variability in the influent characteristics and fluctuations within each reactor of the A2O+AO process. By employing a time-lag approach based on the hydraulic retention time (HRT), artificial intelligence (AI) selects suitable input (i.e., pH, temperature, total dissolved solid (TDS), NH3-N, and NO3-N) and output (COD and TN) data pairs for training, minimizing the error between predicted and observed values. Data collected over two years from the actual A2O+AO process were utilized. The ensemble model adopted machine learning-based XGBoost for COD and TN predictions. The dynamic ensemble model outperformed the static ensemble model, with the mean absolute percentage error (MAPE) for the COD ranging from 9.5% to 15.2%, compared to the static ensemble model’s range of 11.4% to 16.9%. For the TN, the dynamic model’s errors ranged from 9.4% to 15.5%, while the static model showed lower errors in specific reactors, particularly in the anoxic and oxic stages due to their stable characteristics. These results indicate that the dynamic ensemble model is suitable for predicting water quality in WWTPs, especially as variability may increase due to external environmental factors in the future.