In this study, the influences of NH4
+ ions and the thin electrolyte layer (TEL) thickness on the corrosion behavior of the AZ9D magnesium alloy in NH4+‐containing environments were investigated by electrochemical measurements and surface characterization. The experimental results indicate that NH4+ greatly accelerates the corrosion of AZ91D magnesium alloy whether in a bulk solution or in a TEL. As the TEL thickness decreasing, the corrosion resistance of the AZ91D magnesium alloy is strengthened. According to the corrosion morphology, electrochemical analysis, and characterization analysis of corrosion products, the corrosion mechanism of AZ91D under TELs with different thicknesses is divided into three stages: (a) uniformly distributed corrosion pits with deep depth and large size when TEL thickness is higher than or equal to 500 μm; (b) slightly corrosion with randomly distributed corrosion pits and the accumulation of small amount of corrosion product when TEL thickness is between 100 μm and 200 μm; (c) no corrosion pit with only deposition of corrosion product when TEL thickness is lower than or equal to 100 μm. Among which, the roles of NH4+, TEL thickness, and corrosion product are emphasized and discussed in the corrosion process of AZ91D magnesium alloy under TEL with different thicknesses.