The electronic properties of lanthanide (from Eu to Tm) impurities in wurtzite gallium nitride and zinc oxide were investigated by first principles calculations, using an all electron methodology plus a Hubbard potential correction. The results indicated that the 4f-related energy levels remain outside the bandgap in both materials, in good agreement with a recent phenomenological model, based on experimental data. Additionally, zinc oxide doped with lanthanide impurities became an n-type material, showing a coupling between the 4f-related spin polarized states and the carriers. This coupling may generate spin polarized currents, which could lead to applications in spintronic devices.