Particulate matter pollution is recognized globally as one of the most hazardous forms of air pollution, profoundly impacting environmental integrity and public health. Key metrics for assessing this pollution include the Air Quality Index (AQI) and fine particulate matter with diameters ≤2.5 μm (PM2.5). These indicators are closely associated with severe health consequences, such as premature death from chronic exposure. While traditional statistical methods have been employed in some studies to evaluate AQI and PM2.5, the application of advanced machine learning techniques has been limited. This research employs deep learning and artificial neural networks (ANN) to forecast AQI and PM2.5 levels in Baghdad, Iraq. The study utilizes an extensive dataset from July 1, 2016, to December 12, 2021, comprising over 48,000 data points for AQI and PM2.5. Time serves as an independent input variable influencing these dependent variables. The analysis employs a diverse set of machine learning algorithms, including random forest, decision tree, K-Nearest Neighbors (KNN), Multi-Layer Perceptron (MLP), and Long Short-Term Memory networks (LSTM). The findings demonstrate that MLP and LSTM models outperform other methods, providing the most accurate predictions. The correlation coefficients were 0.977 and 0.983 for the prediction of AQI and 0.973 and 0.985 for the prediction of PM2.5 using MLP and LSTM, respectively. In addition, the outcomes showed that both AQI and PM2.5 were within the moderate to unhealthy ranges, and their distribution levels pointed to the need for addressing air quality in Baghdad city. Furthermore, this study contributes to the burgeoning field of machine learning applications in environmental science by establishing a robust and nuanced predictive framework for evaluating air quality. It highlights the potential of deep learning in public health applications and offers actionable insights for policymaking to mitigate air pollution and its adverse effects.