  We compute the exact value of the essential norm of a generalized Hilbert
matrix operator acting on weighted Bergman spaces $A^p_v$ and weighted Banach
spaces $H^\infty_v$ of analytic functions, where $v$ is a general radial
weight. In particular, we obtain the exact value of the essential norm of the
classical Hilbert matrix operator on standard weighted Bergman spaces
$A^p_\alpha$ for $p>2+\alpha, \, \alpha \ge 0,$ and on Korenblum spaces
$H^\infty_\alpha$ for $0 < \alpha < 1.$ We also cover the Hardy space $H^p, \,
1 < p < \infty,$ case. In the weighted Bergman space case, the essential norm
of the Hilbert matrix is equal to the conjectured value of its operator norm
and similarly in the Hardy space case the essential norm and the operator norm
coincide. We also compute the exact value of the norm of the Hilbert matrix on
$H^\infty_{w_\alpha}$ with weights $w_\alpha(z)=(1-|z|)^\alpha$ for all $0 <
\alpha < 1$. Also in this case, the values of the norm and essential norm
coincide.
