With the explosive growth of web services, the increasing sparse and dynamic QoS (quality of service) data pose a great challenge to QoS prediction in service recommendation. How to fully utilize the contextual information of service invocation and their potential relationships becomes the key to improving the accuracy of QoS prediction. In this paper, a spatial context-aware time series forecasting (SCATSF) framework is proposed for QoS prediction by considering both the temporal and the spatial context of users and services. SCATSF has three main parts: time-aware neighbors selection, spatial context-aware interaction learning and time series forecasting for QoS prediction. First, a novel time series similarity (TSS) is proposed to measure the similarity of users or services based on time-varying QoS fluctuation, in order to select appropriate neighbors for the target user or service. Furthermore, the contextual information of neighbors, as well as the contextual information of users and services, are both integrated to enrich the spatial context of service invocation, and a pairwise multi-layer deep network (PMLDN) is developed to consolidate multiple features and to learn feature interactions in pairs. With the help of spatial contextual information and time-aware QoS information, a spatial context-aware GRU model (SCA-GRU) is finally present to complete the time series forecasting for QoS prediction. Experimental results on the prediction of response time in a real-world dataset demonstrate that our SCATSF approach can effectively utilize spatio-temporal contextual information, so that it can achieve higher accuracy than many existing methods.