  We present a unified treatment of three cases of quasi-exactly solvable
problems, namely, charged particle moving in Coulomb and magnetic fields, for
both the Schr\"odinger and the Klein-Gordon case, and the relative motion of
two charged particles in an external oscillator potential. We show that all
these cases are reducible to the same basic equation, which is quasi-exactly
solvable owing to the existence of a hidden $sl_2$ algebraic structure. A
systematic and unified algebraic solution to the basic equation using the
method of factorization is given. Analytic expressions of the energies and the
allowed frequencies for the three cases are given in terms of the roots of one
and the same set of Bethe ansatz equations.
