  In this article we have discovered a close relationship between the
(algebraic) Bethe Ansatz equations of the spin $s$ XXZ model of a finite size
and the $q$-Sturm-Liouville problem. We have demonstrated that solutions of the
Bethe Ansatz equations give rise to the polynomial solutions of a second order
$q$-difference equation in terms of Askey-Wilson operator. The more general
form of Bethe Ansatz equations and the mathematical problems relevant to the
physics of XXZ model are discussed. Furthermore, the similar correspondence
between Bethe Ansatz equations of XXX model and the Sturm-Liouville type
difference equation in terms of Wilson operator has also been found.
