Shale gas flowback and produced water (SGFPW) represent a reservoir of diverse and valuable halophilic microbial resources with profound implications for both shale gas production and SGFPW treatment strategies. However, current research is limited, especially in China. To address this gap, we conducted an extensive study of the microbial community compositions within SGFPW originating from three prominent shale gas blocks in the Sichuan Basin, China. Our findings underscored the coexistence of halotolerant and halophilic bacteria, methylotrophic archaea, and eukaryotes within SGFPW, revealing a remarkably intricate microbial ecosystem. Intriguingly, the archaeal community structure exhibited striking similarity across all SGFPW samples, implying a consistent composition in this regard. Moreover, salinity was identified as a pivotal factor shaping the bacterial community structure in SGFPW. Although divergence in species and abundance of core microbial genera was observed among distinct SGFPW samples, their dominant potential functions remained remarkably consistent. These functions encompassed sulfate reduction, methane production, denitrification, acid production, and degradation of characteristic organic matter of SGFPW. Our comprehensive study significantly advances the comprehension of the microbial community structure within SGFPW, thereby offering valuable insights to augment the overall efficiency of SGFPW management and develop efficient SGFPW biological treatment technologies.