Because of its anticancer, anti-inflammatory, and antibiotic properties, berberine has been used extensively in medication. The extensive production of berberine results in the generation of wastewater containing concentrated residual berberine. However, to date, limited related studies on the biological treatment of berberine wastewaters have been carried out. A lab-scale anaerobic baffled reactor (ABR)–aerobic granular sludge (AGS) process was developed for berberine removal from synthetic wastewater. The system showed effective removal of the berberine. In order to better understand the roles of the bacterial community, the ABR–aerobic granular sludge system was operated in the state with the highest BBR removal rate in this study. The bacterial community dynamics were studied using the 16S rDNA clone library. The results showed that the hybrid ABR-AGS process achieved 92.2% and 94.8% overall removals of berberine and COD, respectively. Bacterium was dominant species in ABR, while the CFB group bacteria and Betaproteobacteria were dominant species in AGS process. The uncultured bacterium clone B135, Bacillus endophyticus strain a125, uncultured bacterium mle1-42, uncultured bacterium clone OP10D15, and uncultured bacterium clone B21.29F54 in ABR, and uncultured bacterium clone F54, uncultured bacterium clone ZBAF1-105, uncultured bacterium clone SS-9, and uncultured bacterium clone B13 in AGS process were identified as functional species in the biodegradation of berberine and/or its metabolites. Both anaerobic and aerobic bacterial communities could adapt appropriately to different berberine selection pressures because the functional species’ identical functions ensured comparable pollutant removal performances. The information provided in this study may help with future research in gaining a better understanding of berberine biodegradation.