Fluids released from subducting slabs profoundly affect mantle composition, rock melting points, and arc magma generation. However, identifying fluid sources (sediments, crust, or mantle) and their ascent paths remains challenging. Magnesium isotopes are potential tracers for subduction-related fluids, though their behavior during hydrous peridotite dehydration remains unclear. Here we determined the equilibrium magnesium isotope fractionation factors between aqueous fluids and hydrous peridotitic minerals using first-principles calculations. Aqueous fluids prefer heavy magnesium isotopes relative to mantle silicate minerals, indicating that fluids released during hydrous peridotite dehydration are enriched in heavy magnesium isotopes relative to the residual minerals. Our simulations proposed that magnesium isotope variations in arc lavas from different subduction zones could be attributed to different dehydration reactions influenced by subduction zone thermal structures. This study highlights the potential of magnesium isotopes for tracing fluids originating from subducting hydrated mantle, providing insights into the thermal structure of various subduction zones.