Magnesium hydroxide (Mg(OH)2) is commonly used as flame retardant chemical additive in polymers. In this study, the effect of Mg(OH)2 on pore structure and mechanical properties of cement mortar is quantitatively investigated through compression tests, NMR tests, and SEM observations. The results show that the compressive strength and elastic modulus increase first and then decrease with the content of Mg(OH)2, and the optimum addition of Mg(OH)2 is about 10 %. The addition of magnesium hydroxide improves the high-temperature resistance and mechanical properties of cement mortar. Compared with the compressive strength before heating, the strength loss varies from 0.13 % to 4.66 % after exposure at 200 °C, that of loss ranges from 26.16 % to 34.53 % after exposure at 400 °C, and that of loss ranges from 80.98 % to 86.19 % at 600 °C. The content of Mg(OH)2 makes the strength of specimens after high-temperature exposure higher than that of specimens without addition. The re-curing process makes the compressive strength of the specimens increase, with the highest increase rate of strength at 400 °C. The pore growth rate of the specimens after high-temperature exposure decreases with Mg(OH)2, and the specimen with 15 % Mg(OH)2 has the smallest pore growth rate. Through SEM observations, mortar with the content of Mg(OH)2 can improve the repair ability and strength of mortar after being exposed to high-temperature. The total pore fractal dimension of the specimens after exposure to different temperatures was found to have a negative correlation with the content of magnesium hydroxide. The study demonstrates the potential of Mg(OH)2 as an inorganic flame retardant for improving the mechanical properties and high-temperature resistance of cement mortar.