Anodizing of AZ91D magnesium alloy in the alkaline borate-potassium hydrogen tartrate (PHT) environmental friendly electrolyte was studied. The effect of PHT on the anodizing process and anodic film properties was investigated by scanning electron microscopy (SEM), X-ray diffraction (XRD), energy dispersive spectrometry (EDS), and potentiodynamic polarization. The results showed that the anodizing parameters, surface morphology, thickness, phase structure, and corrosion resistance of the anodic film were strongly dependent on the concentration of PHT. Moreover, the anodizing mechanism of the AZ91D magnesium alloy in the presence of PHT was also studied. That is, by adsorption on the surface of magnesium alloy, PHT decreases the anodizing current density and make the anodizing condition moderate, which is conducive to the performance improvement of the anodic film.