High-precision Mg isotopic data are reported for ~100 well-characterized samples (granites, loess, shales and upper crustal composites) that were previously used to estimate the upper continental crust composition. Magnesium isotopic compositions display limited variation in eight I-type granites from southeastern Australia (δ26Mg=-0.25 to -0.15) and in 15 granitoid composites from eastern China (δ26Mg=-0.35 to -0.16) and do not correlate with SiO2 contents, indicating the absence of significant Mg isotope fractionation during differentiation of granitic magma. Similarly, the two S-type granites, which represent the two end-members of the S-type granite spectrum from southeastern Australia, have Mg isotopic composition (δ26Mg=-0.23 and -0.14) within the range of their potential source rocks (δ26Mg=-0.20 and +0.15) and I-type granites, suggesting that Mg isotope fractionation during crustal anatexis is also insignificant. By contrast, δ26Mg varies significantly in 19 A-type granites from northeastern China (-0.28 to +0.34) and may reflect source heterogeneity.Compared to I-type and S-type granites, sedimentary rocks have highly heterogeneous and, in most cases, heavier Mg isotopic compositions, with δ26Mg ranging from -0.32 to +0.05 in nine loess from New Zealand and the USA, from -0.27 to +0.49 in 20 post-Archean Australian shales (PAAS), and from -0.52 to +0.92 in 20 sedimentary composites from eastern China. With increasing chemical weathering, as measured by the chemical index of alternation (CIA), δ26Mg values show a larger dispersion in shales than loess. Furthermore, δ26Mg correlates negatively with δ7Li in loess. These characteristics suggest that chemical weathering significantly fractionates Mg isotopes and plays an important role in producing the highly variable Mg isotopic composition of sedimentary rocks.Based on the estimated proportions of major rock units within the upper continental crust and their average MgO contents, a weighted average δ26Mg value of -0.22 is derived for the average upper continental crust. Our studies indicate that Mg isotopic composition of the upper crust is, on average, mantle-like but highly heterogeneous, with δ26Mg ranging from -0.52 to +0.92. Such large isotopic variation mainly results from chemical weathering, during which light Mg isotopes are lost to the hydrosphere, leaving weathered products (e.g., sedimentary rocks) with heavy Mg isotopes.