SummaryAs the most abundant and genetically diverse biological entities, viruses significantly influence ecological, biogeographical and evolutionary processes in the ocean. However, the biogeography of marine viruses and the drivers shaping viral community are unclear. Here, the biogeographic patterns of T4‐like viruses and the relative impacts of deterministic (environmental selection) and dispersal (spatial distance) processes were investigated in the northern South China Sea. The dominant viral operational taxonomic units were affiliated with previously defined Marine, Estuary, Lake and Paddy Groups. A clear viral biogeographic pattern was observed along the environmental gradient from the estuary to open sea. Marine Groups I and IV had a wide geographical distribution, whereas Marine Groups II, III and V were abundant in lower‐salinity continental or eutrophic environments. A significant distance‐decay pattern was noted for the T4‐like viral community, especially for those infecting cyanobacteria. Both deterministic and dispersal processes influenced viral community assembly, although environmental selection (e.g. temperature, salinity, bacterial abundance and community, etc.) had a greater impact than spatial distance. Network analysis confirmed the strong association between viral and bacterial community composition, and suggested a diverse ecological relationship (e.g. lysis, co‐infection or mutualistic) between and within viruses and their potential bacterial hosts.