Antibiotics are frequently detected in wastewater, but often are poorly removed in conventional wastewater treatment processes. Combining microalgal and nitrifying bacterial processes may provide synergistic removal of antibiotics and ammonium. In this research, we studied the removal of the antibiotic sulfamethoxazole (SMX) in two different reactors: a conventional nitrifying bacterial membrane aerated biofilm reactor (bMABR) and algal-bacterial membrane aerated biofilm reactor (abMABR) systems. We investigated the synergistic removal of antibiotics and ammonium, antioxidant activity, microbial communities, antibiotic resistance genes (ARGs), mobile genetic elements (MGEs), and their potential hosts. Our findings show that the abMABR maintained a high sulfamethoxazole (SMX) removal efficiency, with a minimum of 44.6 % and a maximum of 75.8 %, despite SMX inhibition, it maintained a consistent 25.0 % ammonium removal efficiency compared to the bMABR. Through a production of extracellular polymeric substances (EPS) with increased proteins/polysaccharides (PN/PS), the abMABR possibly allowed the microalgae-bacteria consortium to protect the bacteria from SMX inactivation. The activity of antioxidant enzymes caused by SMX was reduced by 62.1–98.5 % in the abMABR compared to the bMABR. Metagenomic analysis revealed that the relative abundance of Methylophilus, Pseudoxanthomonas, and Acidovorax in the abMABR exhibited a significant positive correlation with SMX exposure and reduced nitrate concentrations and SMX removal. Sulfonamide ARGs (sul1 and sul2) appeared to be primarily responsible for defense against SMX stress, and Hyphomicrobium and Nitrosomonas were the key carriers of ARGs. This study demonstrated that the abMABR system has great potential for removing SMX and reducing the environmental risks of ARGs.