To understand the formation process of massive stars, we present a multiscale and multiwavelength study of the W31 complex hosting two extended H ii regions (i.e., G10.30-0.15 (hereafter, W31-N) and G10.15-0.34 (hereafter, W31-S)) powered by a cluster of O-type stars. Several Class i protostars and a total of 49 ATLASGAL 870 μm dust clumps (at d = 3.55 kpc) are found toward the H ii regions where some of the clumps are associated with the molecular outflow activity. These results confirm the existence of a single physical system hosting the early phases of star formation. The Herschel 250 μm continuum map shows the presence of a hub-filament system (HFS) toward both W31-N and W31-S. The central hubs harbor H ii regions and they are depicted with extended structures (with T
d
∼ 25–32 K) in the Herschel temperature map. In the direction of W31-S, an analysis of the NANTEN2 12CO(J = 1−0) and SEDIGISM 13CO(J = 2−1) line data supports the presence of two cloud components around 8 and 16 km s−1, and their connection in velocity space. A spatial complementary distribution between the two cloud components is also investigated toward W31-S, where the signposts of star formation, including massive O-type stars, are concentrated. These findings favor the applicability of cloud–cloud collision (CCC) around ∼2 Myr ago in W31-S. Overall, our observational findings support the theoretical scenario of CCC in W31, which explains the formation of massive stars and the existence of HFSs.