To clarify the origin of the figure of merit in the thermoelectric material Mg2Si, we performed extended X-ray absorption fine structure (EXAFS) analysis and hard X-ray photoelectron spectroscopy (HAXPES). We elucidate the local structures and electronic states of Mg2Si, especially focusing on the contribution of doped Sb. EXAFS analysis revealed that Sb substituted Si and that the nearest neighbor distance expanded around Sb. Furthermore, HAXPES confirmed the formation of density of states near the Fermi level by co-doping with 0.5% Zn and 0.5% Sb. The comparison of the experimental and theoretical results suggested that the density of states at the Fermi level was due to the tail of the conduction band, and it was filled by the electrons provided by doped Sb. From a microscopic viewpoint, the results obtained in this study suitably explain why Sb doping increases electrical conductivity and decreases thermal conductivity in Mg2Si, as reported in a previous study.