Sedimentary microorganisms play crucial roles in maintaining the functional stability of aquatic ecosystems. However, their taxonomic composition and assembly processes are not well known in estuarine–coastal margins because of their complex environment. We investigated microbial communities, co-occurrence relationships, and underlying mechanisms in 33 surface sediment samples collected in the Jiulong River Estuary and the Taiwan Strait to reveal their composition dynamics. The abundance, diversity, and composition of microorganisms demonstrated obvious spatial variables. Methanobacterium and Methanosarcina, as well as Candidatus_Nitrosopumilus and Nitrososphaeraceae were the main methanogenic and ammonia-oxidizing archaea, with an average abundance of more than 5.91% and 4.27%, respectively. Along with a salinity gradient increase, the relative abundance of methanogenic archaea (from 42.9% to 16.6%) contrasted with the trend of ammonia-oxidizing archaea (from 6.04% to 18.7%). The number of methanogenic archaea gradually decreased with increasing geographic distance (p < 0.05), whereas ammonia-oxidizing archaea showed no significant change (p > 0.05). In co-occurrence patterns, closer inter-taxa connections were observed among archaea–archaea and bacteria–bacteria than in archaea–bacteria, which indicated that coexistence within the same kingdom was greater than interaction between different kingdoms in shaping the community structure along the salinity gradient. Furthermore, null model analyses of the microbial community showed that undominated was the most prominent process, explaining over 44.9% of community variation, followed by heterogeneous selection and dispersal limitation, which contributed to 27.7% and 16.3%, respectively. We demonstrated that stochasticity, rather than determinism, regulates community assembly. These results further highlight that intra-kingdom co-occurrence and stochastic processes shape the structure and assembly of microbial communities in estuarine–coastal margins.