Inhibition of nitrite oxidizing bacteria (NOB) is important for efficient wastewater treatment via anammox. Here, a novel strategy was demonstrated, which based on the detachment and reattachment of the biofilm to establish partial nitrification and anammox in a membrane aerated biofilm reactor (MABR). The results showed that using free ammonia as the sole inhibitor to start up partial nitrification took more time, and NOB acclimated to the free ammonia inhibition. Detaching the biofilm made it possible for free ammonia to contact NOB in deeper zones of the biofilm while at the same time washing NOB out of the reactor. Nitrite accumulation efficiency (NAE) increased to 70 % in 50 days when both high ammonia loading and biofilm reattachment were applied. With a short hydraulic retention time and high concentrations of ammonia and nitrite, anammox activity appeared in the reactor and resulted in a nitrogen removal efficiency of 60 %. Microbial community analysis indicated that Nitrosomonas, Nitrospira, and Candidatus Brocadia were the main functional taxa. Anaerobic ammonia oxidizing bacteria (AnAOB) proliferated within the biofilm, inhibiting NOB growth by competing for nitrite. Endogenous denitrifying bacteria also grew, coexisting with AnAOB. Predicted abundance of genes related to fermentation correlated with those involved in denitrification, indicating the possibility of heterotrophic denitrification. These findings help further our understanding of biofilm control-based strategies for NOB management and have implications for establishing autotrophic nitrogen removal using MABRs.