Traffic flow prediction is crucial for intelligent transportation systems (ITS), providing valuable insights for traffic control, route planning, and operation management. Existing work often separately models the spatial and temporal dependencies and primarily relies on predefined graphs to represent spatio-temporal dependencies, neglecting the traffic dynamics caused by unexpected events and the global relationships among road segments. Unlike previous models that primarily focus on local feature extraction, we propose a novel collaborative local–global learning model (LOGO) that employs spatio-temporal attention (STA) and graph convolutional networks (GCN). Specifically, LOGO simultaneously extracts hidden traffic features from both local and global perspectives. In local feature extraction, a novel STA is devised to directly attend to spatio-temporal coupling interdependencies instead of separately modeling temporal and spatial dependencies, and to capture in-depth spatio-temporal traffic context with an adaptive graph focusing on the dynamics in traffic flow. In global feature extraction, a global correlation matrix is constructed and GCNs are utilized to propagate messages on the obtained matrix to achieve interactions between both adjacent and similar road segments. Finally, the obtained local and global features are concatenated and fed into a gated aggregation to forecast future traffic flow. Extensive experiments on four real-world traffic datasets sourced from the Caltrans Performance Measurement System (PEMS03, PEMS04, PEMS07, and PEMS08) demonstrate the effectiveness of our proposed model. LOGO achieves the best performance over 18 state-of-the-art baselines and the best prediction performance with the highest improvement of 6.06% on the PEMS07 dataset. Additionally, two real-world case studies further substantiate the robustness and interpretability of LOGO.