We present a joint theoretical and experimental study of the oxygen K-edge spectra for LaFeO 3 and homovalent Ni-substituted LaFeO 3 (LaFe 0.75 Ni 0.25 O 3), using first-principles simulations based on density-functional theory with extended Hubbard functionals and x-ray absorption near edge structure (XANES) measurements. Ground-state and excited-state XANES calculations employ Hubbard onsite U and intersite V parameters determined from first principles and the Lanczos recursive method to obtain absorption cross sections, which allows for a reliable description of XANES spectra in transition-metal compounds in a very broad energy range, with an accuracy comparable to that of hybrid functionals but at a substantially lower cost. We show that standard gradient-corrected exchange-correlation functionals fail in capturing accurately the electronic properties of both materials. In particular, for LaFe 0.75 Ni 0.25 O 3 they do not reproduce its semiconducting behavior and provide a poor description of the pre-edge features at the O K edge. The inclusion of Hubbard interactions leads to a drastic improvement, accounting for the semiconducting ground state of LaFe 0.75 Ni 0.25 O 3 and for good agreement between calculated and measured XANES spectra. We show that the partial substitution of Ni for Fe affects the conduction-band bottom by generating a strongly hybridized O(2p)-Ni(3d) minority-spin empty electronic state. The present work, based on a consistent correction of self-interaction errors, outlines the crucial role of extended Hubbard functionals to describe the electronic structure of complex transition-metal oxides such as LaFeO 3 and LaFe 0.75 Ni 0.25 O 3 and paves the way to future studies on similar systems.