The prediction of air pollution is of great importance in highly populated areas because it has a direct impact on both the management of the city's economic activity and the health of its inhabitants. In this work, the spatio-temporal behavior of air quality in Metropolitan Lima was evaluated and predicted using the recurrent artificial neural network known as Long-Short Term Memory networks (LSTM). The LSTM was implemented for the hourly prediction of PM10 based on the past values of this pollutant and three meteorological variables obtained from five monitoring stations. The model was evaluated under two validation schemes: the hold-out (HO) and the blocked-nested cross-validation (BNCV). The simulation results show that periods of low PM10 concentration are predicted with high precision. Whereas, for periods of high contamination, the LSTM network with BNCV has better predictability performance. In conclusion, recurrent artificial neural networks with BNCV adapt more precisely to critical pollution episodes and have better performance to forecast this type of environmental data, and can also be extrapolated to other pollutants.