The rectal anal junction (RAJ) is the major colonization site of Shiga toxin-producing Escherichia coli (STEC) O157 in beef cattle, leading to transmission of this foodborne pathogen from farms to food chains. To date, there is limited understanding on whether mucosa-attached microbiome has a profound impact on host-STEC interactions. In this study, the active RAJ mucosa-attached microbiota and its potential role in host immunity-STEC-commensal interactions were investigated using RAJ mucosal biopsies collected from calves orally challenged with two STEC O157 strains with or without functional stx2a (stx2a + or stx2a-). The results revealed that shifts of microbial diverstives, topological, and assembly patterns were subjected to stx2a production post-challenge and Paeniclostridium and Gallibacterium being the keystone taxa for both microbial interactions and assembly. Additional mucosal transcriptome profiling showed stx2a-dependent host immune responses (i.e. B and T cell signaling, antigen processing and presentation) post-challenge. Further integrated analysis revealed that mucosa-attached beneficial microbes (i.e. Provotella, Faecalibacterium, and Dorea) interacted with host immune genes pre-challenge to maintain host homeostasis, however, opportunistic pathogenic microbes (i.e. Paeniclostridium) could interact with host immune genes after the STEC O157 colonization and interactions were stx2a-dependent. Furthermore, bacterial predicted functions involved in pathogen (O157 and Paeniclostridium) colonization and metabolism were related to host immunities. These findings suggest that host-microbe interactions could shift from beneficial to opportunistic pathogenic bacteria-driven during the pathogen colonization and be dependent on the production of particular virulence factors, highlighting the potential regulatory role of mucosa-attached microbiota in affecting pathogen-commensal-host interactions under STEC O157 infection in calves.