NOVELTY - The method comprises: concentrating or diluting the sludge; carrying out alkaline hydrolysis treatment; measuring molar concentration of phosphate in the sludge; adding magnesium/phosphorus in magnesium salt aqueous solution; stirring for 10-120 minutes to precipitate magnesium ammonium phosphate; separating supernatant; carrying out anaerobic treatment; and naturally drying to obtain magnesium ammonium phosphate crude product; introducing the obtained supernatant into an anaerobic reactor; inoculating anaerobic granular sludge; and introducing reaction gas for producing methane.    USE - The method is useful for treating sewage to produce methane (claimed).    ADVANTAGE - The method is capable of producing methane using nutrient elements in the residual sludge with low energy consumption.    DETAILED DESCRIPTION - The method comprises: concentrating or diluting the sludge to a concentration of 10-40 g/l and moisture content of 96-99%; carrying out alkaline hydrolysis treatment for the sludge; measuring molar concentration of phosphate in the sludge; adding magnesium/phosphorus in magnesium salt aqueous solution of ratio 0.8:2; stirring for 10-120 minutes to precipitate magnesium ammonium phosphate; separating supernatant; carrying out anaerobic treatment; and naturally drying to obtain magnesium ammonium phosphate crude product; introducing the obtained supernatant into an anaerobic reactor; inoculating 10-60 vol.% of anaerobic granular sludge; and introducing reaction gas for 72 hours for production methane of 200-400 ml CH4/g chemical oxygen demand (COD). The alkaline hydrolysis step is carried out by injecting surplus amount of sludge into an alkaline hydrolysis reactor, stirring for 50-350 revolutions per minute, carrying out first level alkaline hydrolysis for 0.5-8 hours at controlled pH of 8.5-10, injecting water of 2/7-5/7X of volume, centrifuging at 2000-6000 revolutions per minute; filtering the mixture using a belt pressure filter or plate frame press filter to obtain supernatant, carrying out second level alkaline hydrolysis to obtain alkali solution that is rich in organic matter, ammonia nitrogen and phosphate. The soluble chemical oxygen demand concentration of the alkali solution reaches to 2000-10000 mg/l. The second level alkaline hydrolysis is carried out to neutralize the alkali solution for adjusting pH value of the solution to be 7.5-10, without using acid treatment. The supernatant comprises more than 70% of organic matter that is converted into methane. The reaction gas is ammonia or nitrogen. The anaerobic reactor includes upper flow anaerobic sludge blanket reactor (UASB) or an anaerobic expansion grain sludge bed (EGSB).