Air pollution poses a significant issue in numerous cities worldwide, impacting public health and the environment. We study three significant cities under the Dhaka division, including Kuril Bishow Road, Uttara, and Tongi. Traditional air quality monitoring methods often need more coverage and accuracy. Leveraging Internet of Things (IoT) technology as well as machine learning (ML) algorithms, this study deploys an IoT-based sensor network using Arduino boards and various devices, including MQ135, DHT22, PM2.5, MQ9, and dust sensors to gather real-time values on air pollutants. The gathered data, including sulfur dioxide, ozone, particulate matter 2.5, nitrogen dioxide, particulate matter 10, as well as carbon monoxide, provides a comprehensive view of city pollution levels. ML models such as linear regression, decision trees, K-Nearest Neighbors (KNN), Naive Bayes (NB), Gradient Boosting (GB), and Random Forest classifiers are applied to predict pollution levels using environmental parameters. The Random Forest classifier achieves an impressive prediction accuracy of . Evaluation metrics, including precision, recall, F1 score, Kappa score, mean square error (MSE), root mean square error(RMSE), along mean absolute error (MAE), are used to assess the performance of the models. This study demonstrates the potential of IoT technology along with ML algorithms in accurately predicting air pollution levels, aiding in environmental management and public health efforts in urban areas.