The local structure around Er and Eu atoms introduced into GaN epilayers was studied by means of Extended X-ray Absorption Fine Structure above the appropriate rare-earth X-ray absorption edge. The samples were doped in situ during growth by Molecular Beam Epitaxy. The formation of ErN clusters was found in samples with high average Er concentrations of 32±6% and 12.4±0.8%, estimated by Wavelength Dispersive X-ray analysis. When the average Er concentration is decreased to 6.0±0.2%, 1.6±0.2% and 0.17±0.02%, Er is found in localised clusters of ErGaN phase with high local Er content. Similar behaviour is observed for Eu-doped samples. For an average Eu concentration of 30.5±0.5% clusters of pure EuN occur. Decreasing the Eu concentration to 10.4±0.5% leads to EuGaN clusters with high local Eu content. However, for a sample with an Eu concentration of 14.2±0.5% clustering of Eu was not observed.