Energy consumption is steadily increasing in the Middle East owing to rapid population growth, industrial expansion, and economic development. It is imperative to accurately forecast energy consumption for strategic planning, infrastructure development, and to establish long-term sustainable projects. However, it is challenging to accurately forecast energy consumption due to the nonlinear and complex nature of data. With the advent of Artificial Intelligence across various fields, it is imperative to employ Machine Learning (ML) models, such as Gated Recurrent Unit (GRU), Long Short-Term Memory (LSTM), and eXtreme Gradient Boosting (XGBoost), to forecast primary energy consumption in the Middle East over the next decade, from 2025 to 2034. These models used historical data from 538.7785 TWh in 1965 to 11597.1875 TWh in 2024. Metrics such as MAE, MSE, and R2 were used to evaluate the models’ performance. Comparing models’ effectiveness on the training and test datasets using R2, the GRU achieved an optimal balance between accuracy and generalization (0.9905, 0.8127). The LSTM showed stable performance; however, it had comparatively low predictive capability (0.7575, 0.7666). On the contrary, XGBoost was severely overfitted owing to the limited dataset, and it lacked temporal learning capability (0.9999,-5.0394). Additionally, the optimized model (GRU modeling) was trained using window size 5 with 20 hidden units, and a 0.2 dropout rate was applied to enhance generalization. The model used the Adam optimizer and Mean Squared Error (MSE) loss during training. Based on the GRU algorithm, primary energy consumption is forecast to increase from 11,671.0380 TWh in 2025 to 13,427.7031 TWh in 2034, which reflects about 15% growth over the forecasting period. This study will help policymakers and industry stakeholders to make strategic decisions on energy planning and sustainability.