Synthetic wastewater was used to culture granular sludge for 21 weeks at three sequencing batch reactor activated sludge process (SBR) under different photoperiods. The growth of algae changed granular oxygen distribution, which affected the composition of microbial communities. Different photoperiods were able to alter the formation of granular sludge and the microbial community granules. In short photoperiod (12 h/d) sludge could generate symbiotic algae-bacteria granules in the SBR. By contrast, the long photoperiod (24 h/d) promotes the growth of algae and Ascomycota early, and then inhibits algae, especially chlorophyta (only 1.18%). In the end, algae-bacteria-fungi granules were formed in long photoperiod (LP). By GC-MS and model calculation, the lipid content of algae-bacteria granules was 33.71% more than that of pure aerobic granular sludge. However, the proportion of unsaturated fatty acids in algae-bacteria granules was as high as 43%, resulting in the quality of biodiesel prepared from algae-bacteria granule being slightly worse than that prepared from pure aerobic granular sludge. But both of them were better than biodiesel prepared from pure algae. The biodiesel content of algae-bacteria granule in short photoperiod (SP) and LP were 68.79 and 70.66 mg/g, respectively, which was better than that of pure aerobic particles (52.30 mg/g). Therefore, the formation of algae-bacteria granules is an effective way to remove nutrients and reduce harvesting costs.