We have previously shown that the corrosion behavior of ternary NdFeB magnets is affected by their oxygen, carbon, and nitrogen contents. The corrosion was measured in autoclaves which give accelerated testing environments of high heat and humidity. In this study, we relate this corrosion behavior in both NdFeB and NdFeCoA1B magnets to effects upon their microstructure. When the oxygen and carbon contents are low in ternary NdFeB magnets, a thick Nd-rich phase (alpha-Nd and/or NdOx) forms along grain boundaries and their triple junctions. As the oxygen and carbon contents increase, the Nd-rich coating along the boundaries becomes thinner and agglomerates into the triple junctions. With thin grain boundaries, the pathways for corrosion propagation are hindered, thus improving corrosion resistance. With increases in oxygen, the alpha-Nd and unstable NdOx are changed to stable Nd2O3. Nitrogen increases also aid in process of conversion to Nd2O3 which leads to better corrosion resistance. Two different features are seen in the microstructure of NdFeCoAlB magnets. The grain boundary phase (Nd3Co) is very stable. Any oxygen in the system appears as fully oxidized Nd2O3. Easily corroded alpha-Nd and NdOx are not detected. All of these factors combine to produce excellent corrosion resistance in this variety of NdFeCoAlB magnets.