We explore the effect of the external magnetic and Aharonov–Bohm (AB) flux fields on the energy levels of Dirac particle subjects to mixed scalar and vector anharmonic oscillator field in the two-dimensional (2D) space. We calculate the exact energy eigenvalues and the corresponding un-normalized two-spinor-components wave functions in terms of the chemical potential parameter, magnetic field strength, AB flux field and magnetic quantum number by using the Nikiforov–Uvarov (NU) method.