The influence of hydraulic retention time (HRT) on the granulation process, methane-producing capacity, microbial community structure, and pollutant removal efficiency of an up-flow anaerobic sludge blanket (UASB) with simulated municipal wastewater at a mesophilic temperature was investigated. The carbon recovery capacity of the anaerobic fermentation of municipal wastewater at mesophilic temperatures is one of the problems to be investigated for the realisation of carbon neutrality in municipal wastewater treatment plants. In this study, the HRT was gradually shortened (24–6 h), and the effluent chemical oxygen demand (COD), ammonia nitrogen, pH, volatile fatty acid concentration, and specific methanogenic activity (SMA) were investigated. The sludge morphology, the particle size distribution of the different HRT, and changes in the microbial community structure were determined by scanning electron microscopy, wet screening, and high-throughput sequencing. The results indicated that even if the COD concentration was only 300–550 mg/L, with a decrease in HRT, the proportion of granular sludge in the UASB still exceeded 78 %, and the COD removal efficiency reached 82.4 %. The SMA of granular sludge increased with an increase in the size of granules and was 0.289 g CH4-COD/(g VSS d) at an HRT of 6 h, but the proportion of dissolved methane in the effluent accounted for 38–45 % of the total methane production and the proportion of Methanothrix in UASB sludge was 82.44 %. In this study, dense granular sludge was obtained by gradually shortening the HRT to start the UASB, and the lower effluent COD reduced the load of subsequent treatment processes, which could be used as a low carbon/nitrogen ratio influent for activated carbon-activated sludge, activated sludge-microalgae, and partial nitrification-anaerobic ammonia oxidation processes.