The invention discloses a method for processing residual sludge with an integrated process of alkaline hydrolysis preprocessing, nitrogen and phosphorus recovery based on a magnesium ammonium phosphate method and methane production based on anaerobic digestion. The method comprises the steps of: preprocessing residual sludge with a secondary alkaline hydrolysis method to obtain supernate, adding a magnesium salt solution to separate precipitates, subjecting the supernate to anaerobic processing, and drying the precipitates naturally to obtain crude magnesium ammonium phosphate; injecting the supernate into an anaerobic reactor, and inoculating with 10-60% anaerobic granular sludge, wherein the volumetric loading is controlled to be 0.30-0.75kg COD (Chemical Oxygen Demand) / (m<3>.d), and the productivity of methane reaches 200-400mL CH4 / gCOD within 72h. The method disclosed by the invention has the advantages that nutrition elements in the residual sludge are utilized comprehensively, the process is simple and is consistent in flow with low chemical consumption and electricity consumption, methane is recovered while crude magnesium ammonium phosphate is obtained, moreover, residual alkaline solids are beneficial to subsequent processing, and the reduction, stabilization and recycling of the residual sludge are realized comprehensively.