The Dirac equation for an electron in two spatial dimensions in the Coulomb and homogeneous magnetic fields is an example of the so-called quasi-exactly solvable models. The solvable parts of its spectrum were previously solved from the recursion relations. In this work we present a purely algebraic solution based on the Bethe ansatz equations. It is realized that, unlike the corresponding problems in the Schrödinger and the Klein–Gordon cases, here the unknown parameters to be solved for in the Bethe ansatz equations include not only the roots of the wave function assumed, but also a parameter from the relevant operator. We also show that the quasi-exactly solvable differential equation does not belong to the classes based on the algebrasl2.