In this paper, a green inhibitor (pheophorbide) was synthesized, and its inhibition mechanism on AZ91D magnesium alloy in distilled water was studied by electrochemical methods, surface analysis technologies, quantum chemical calculation and molecular dynamics simulation. The effect of chloride ions on the inhibition behavior of pheophorbide was also discussed. The results showed that pheophorbide alleviated the corrosion of AZ91D magnesium alloy, and it still had good inhibition effect with the prolongation of immersion time.The addition of 0.5 mg/L chloride ion improved its inhibition efficiency, but reduced its long-term effectiveness. The adsorption of pheophorbide on the surface of AZ91D magnesium alloy conformed to Langmuir adsorption model. The pheophorbide molecules were adsorbed on the surface of AZ91D magnesium alloy in parallel.