This study aims at optimizing the anaerobic digestion (AD) of biomass in microalgal-based wastewater treatment systems. It comprises the co-digestion of microalgae with primary sludge, the thermal pretreatment (75 °C for 10 h) of microalgae and the role of the hydraulic retention time (HRT) in anaerobic digesters. Initially, a batch test comparing different microalgae (untreated and pretreated) and primary sludge proportions showed how the co-digestion improved the AD kinetics. The highest methane yield was observed by adding 75% of primary sludge to pretreated microalgae (339 mL CH4/g VS). This condition was then investigated in mesophilic lab-scale reactors. The average methane yield was 0.46 L CH4/g VS, which represented a 2.9-fold increase compared to pretreated microalgae mono-digestion. Conversely, microalgae showed a low methane yield despite the thermal pretreatment (0.16 L CH4/g VS). Indeed, microscopic analysis confirmed the presence of microalgae species with resistant cell walls (i.e., Stigioclonium sp. and diatoms). In order to improve their anaerobic biodegradability, the HRT was increased from 20 to 30 days, which led to a 50% methane yield increase. Overall, microalgae AD was substantially improved by the co-digestion with primary sludge, even without pretreatment, and increasing the HRT enhanced the AD of microalgae with resistant cell walls.