Given the prevalence and risk of antibiotics and advantages of the anaerobic ammonium oxidation (anammox) process, this study evaluated and compared the mainstream and sidestream anammox process performance in treating wastewater containing typical β-lactam antibiotic under microaerobic conditions. The mainstream anammox process was able to tolerate higher concentrations of cefalexin under the relatively low dissolved oxygen (DO) concentration, while higher DO slightly reduced the nitrogen removal efficiency of the anammox process, but it was still higher than 70%. In contrast, the sidestream anammox process exhibited a poor tolerance to cefalexin stress. Combined with metagenomics and transcriptomics, the comparative analysis of 154 high-quality metagenomic assembly genomes in anammox consortia revealed the potential mechanism of low DO in mitigating cefalexin stress. Results showed that the expressions of genes related to the dissimilatory nitrate reduction to ammonia process and anammox process were significantly upregulated under low DO condition. As the dominant functional bacteria, Candidatus Kuenenia stuttgartiensis HNU0043 had the detoxification mechanism of •O 2 − metabolism and secondary product H 2 O 2 , which mainly depended on the cooperation of Fe−Mn family superoxide dismutase and catalase. Expressions of genes involved in various carbon metabolism pathways were also detected in Ca. Kuenenia stuttgartiensis HNU0043, explaining the resistance of anammox consortia to antibiotic stress through biodegradation. Therefore, the mainstream anammox process tolerated the antibiotic stress under microaerobic conditions, while low DO was more beneficial for maintaining its stability. This work provides insights into the molecular mechanisms underlying anammox microbiota adaptability to antibiotics and oxygen, further expending the implementation of the anammox process.