Rapid urbanization has precipitated significant anthropogenic pollution (nutrients and pathogens) in urban rivers and their receiving systems, which consequentially disrupted the compositions and assembly of bacterial community within these ecosystems. However, there remains scarce information regarding the composition and assembly of both planktonic and benthic bacterial communities as well as pathogen distribution in such environments. In this study, full-length 16S rRNA gene sequencing was conducted to investigate the bacterial community composition, interactions, and assembly processes as well as the distribution of potential pathogens along a riverine-coastal continuum in Shenzhen megacity, China. The results indicated that both riverine and coastal bacterial communities were predominantly composed of Gammaproteobacteria (24.8 ± 12.6 %), Alphaproteobacteria (16.1 ± 9.8 %), and Bacteroidota (14.3 ± 8.6 %), while sedimentary bacterial communities exhibited significantly higher diversity compared to their planktonic counterparts. Bacterial community patterns exhibited significant divergences across different habitats, and a significant distance-decay relationship of bacterial community similarity was particularly observed within the urban river ecosystem. Moreover, the urban river ecosystem displayed a more complex bacterial co-occurrence network than the coastal ecosystem, and a low ratio of negative:positive cohesion suggested the inherent instability of these networks. Homogeneous selection and dispersal limitation emerged as the predominant influences on planktonic and sedimentary bacterial communities, respectively. Pathogenic genera such as Vibrio, Bacteroides, and Acinetobacter, known for their roles in foodborne diseases or wound infection, were also identified. Collectively, these findings provided critical insights into bacterial community dynamics and their implications for ecosystem management and pathogen risk control in riverine and coastal environments impacted by rapid urbanization.