The nitrogen content of municipal sludge is as high as 2.5~9.0 wt%, which has become an important problem in pollution control during pyrolysis. Recycling nitrogen from municipal sludge not only enables resource utilization, but also reduces the nitrogen-related pollution. In this study, the transformation pathways of nitrogen to resource material and typical pollutants during the municipal sludge pyrolysis process were analyzed. The results showed that the nitrogen species in municipal sludge were mainly protein-N (64.41%), pyridine-N (19.47%) and inorganic-N (16.13%). After pyrolysis at 300 °C, the peptide bond of protein-N was gradually broken down, resulting in the formation of three nitrogenous intermediates (amine-N, nitrile-N and heterocyclic-N) were produced. These intermediates can be transformed to NH3 for resource recovery or to HCN pollutants. Moreover, the full nitrogen transformation pathways of municipal sludge pyrolysis were constructed by the method of Spearman's correlation coefficient and experiment analysis. It was found that NH3 and HCN were mostly generated from the cracking of three nitrogenous intermediates at 600–800 °C. In addition, there was a prominent effect on the transformation of HCN to NH3 with co-presence of calcium minerals in raw sludge. By adding inorganic calcium minerals, NH3 as a recyclable component was prominently improved by 10.30% at 700 °C, while HCN yield was decreased by 53.02% accordingly under the inhibitory effect. The results systematically provided a theoretical support to the possibility of nitrogen recycling for utilization during municipal sludge pyrolysis, as well as to control the transformation of nitrogen elements into pollutants.