Aerobic composting is a useful method for managing and disposing of salvaged algal sludge. To optimize the composting process and improve compost quality, it is necessary to understand the functions and responses of microbial communities therein. This work studied the degradation process of organic matter and the assemblage of bacterial communities in algal sludge composting via 16S rRNA amplicon sequencing. The results showed that 77.08% of the microcystin was degraded during the thermophilic stage of composting, which was the main period for microcystin degradation. Bacterial community composition and diversity changed significantly during the composting, and gradually stabilized as the compost matured. Different composting stages may be dominated by different module groups separately, as shown in the co-occurrence networks of composting bacterial communities. In the networks, all bacteria associated with microcystin degradation were identified as connectors between different module groups. The algal sludge composting process was driven primarily by deterministic processes, and the main driving forces for bacterial community assembly were temperature, dissolved organic carbon, ammonium, and microcystin. At last, by applying the structural equation modeling method, the bacterial communities under influences of physiochemical properties were proved as the main mediators for the microcystin degradation. This study provides valuable insights into the optimization of bacterial communities in composting to improve the efficiency of microcystin degradation and the quality of the compost product.