We have investigated detailed Mg isotopic variations in the lithospheric mantle by analysing olivine in mantle-derived peridotite xenoliths and megacrysts. High-precision in situ analyses of 26Mg/ 24Mg and 25Mg/24Mg are made using a laser-ablation microprobe and MC-ICPMS. Measurements are done using a standard-sample bracketing technique with an in-house olivine standard. Replicate analyses of this standard give a precision of 0.20‰ (2sd) for δ26Mg (= [(26Mg/24Mg) sample/(26Mg/24Mg)standard - 1] × 1000) and 0.12‰ (2sd) for δ25Mg. The analysed olivine grains represent the lithospheric mantle beneath Archean cratons (Siberia, Kaapvaal, Slave) and Phanerozoic fold belts (SE Australia). Results from olivines show significant heterogeneity in the lithospheric mantle: δ26Mg ranges from -3.01‰ to + 1.03‰ and δ25Mg from -1.59‰ to + 0.51‰, relative to the magnesium isotopic standard DSM-3. There is a broad trend from lighter Mg isotopic compositions in depleted xenoliths from Archean mantle to heavier Mg in the less depleted Phanerozoic samples. Samples with petrographic evidence of refertilisation (including modal metasomatism) show large ranges in δMg values within samples. Sheared peridotite xenoliths from the Kaapvaal and Slave Cratons show a shift to higher δMg associated with the introduction of fluids with an 'asthenospheric' signature. Olivine in the least metasomatised peridotites from SE Australia has isotopically light Mg, whereas olivine in cryptically and modally metasomatised peridotites (amphibole ± apatite-bearing) becomes progressively heavier, both absolutely and relative to pyroxene and amphibole, with increasing degrees of metasomatism. The heterogeneity measured in individual samples suggests that Mg isotopic fractionations produced by processes of mantle metasomatism are preserved on the intra-grain scale, and the magnitude of the observed fractionations indicates that diffusion-related (kinetic) processes are important in controlling isotope fractionation at high temperatures. The in situ measurement of Mg isotopes provides a powerful new method for investigating processes in the mantle.