Anodic films are prepared on AZ91D magnesium alloy in the electrolytes with Al2O3、SiC、TiO2、ZrO2 and CeO2 nanoparticles respectively. The oxide nanoparticles are partly embedded in the anodic films during the oxidation process. The film porosity decreases with the addition of oxide nanoparticles. As the film porosity increases, the film microhardness decreases while the bonding strength increases, and the microhardness of the anodic film prepared with SiC nanoparticles is as high as 900.7 HV. The increased interpore distance and the decreased film porosity could decrease the thermal cracking tendency of the anodic films. Particularly, the anodic film prepared with CeO2 nanoparticles does not crack after heating. The crack density increases more quickly than the crack width with the changed pore parameters. After 1200 h immersion in NaCl solution the resistance values of the anodic films prepared in the electrolytes with SiC、TiO2、ZrO2 and CeO2 nanoparticles are still higher than 105 Ω cm2, two orders of magnitude higher than the values of the films prepared with Al2O3 and without oxide nanoparticles, and the film capacity increases very slowly. The anodic film prepared with ZrO2 nanoparticles shows the best corrosion resistance. The better corrosion resistance of the anodic films is attributed to the oxide nanoparticles filling the defect position, changing the film composition and improving the film defect structure.