Diffusion in dilute Mg–X alloys, where X denotes Al, Zn, Sn and Ca impurities, was investigated with first-principles density functional theory in the local density approximation. Impurity diffusion coefficients were computed as a function of temperature using the 8-frequency model which provided the relevant impurity and solvent (Mg) jump frequencies and correlation factors. Minimum energy pathways for impurity diffusion and associated saddle point structures were computed with the climbing image nudged elastic band method. Vibrational properties were obtained with the supercell (direct) method for lattice dynamics. Calculated diffusion coefficients were compared with available experimental data. For diffusion between basal planes, we find D Mg–Ca > D Mg–Zn > D Mg–Sn > D Mg–Al, where D is the diffusion coefficient. For diffusion within a basal plane, the same trend holds except that D Mg–Zn overlaps with D Mg–Al at high temperatures and D Mg–Sn at low temperatures. These trends were explored with charge density contours in selected planes of each Mg–X alloy, the variation of the activation energy for diffusion with the atomic radius of each impurity and the electronic density of states. The theoretical methodology developed herein can be applied to impurity diffusion in other hexagonal materials.