Air pollution imposes great costs on productivity, safety and health of individuals and dictates necessity of a proactive air pollution management. This, in turn, requires powerful tools for air quality modeling. In this article we develop a two-stage procedure for predicting exceedances of the EU legal limits for PM10 and O 3 concentrations using hourly data. Within the first stage we deploy machine learning methods to produce accurate 24-h-ahead forecasts of hourly pollutant concentrations at seven specific locations in the cities of Augsburg and Munich, Germany. The best performance was shown by the Stochastic Gradient Boosting Model-an ensemble tree-based method, especially convenient because of its computational efficiency and robustness to overfitting. Its predictive ability was largely superior to that reported by similar studies. In the second stage, the hourly forecasts were used to predict the exceedances of the EU daily limits for PM10 and O 3 concentrations. For both pollutants we could achieve the average probability of exceedances detection above 80%, while keeping the probability of false alarms at a reasonably low level. Such satisfactory results show that our approach can be successfully applied to anticipate the shocks, which would allow authorities to manage them in the most effective manner.