  Starting with a Lie algebroid ${\cal A}$ over a space $M$ we lift its action
to the canonical transformations on the affine bundle ${\cal R}$ over the
cotangent bundle $T^*M$. Such lifts are classified by the first cohomology
$H^1({\cal A})$. The resulting object is a Hamiltonian algebroid ${\cal A}^H$
over ${\cal R}$ with the anchor map from $\G({\cal A}^H)$ to Hamiltonians of
canonical transformations. Hamiltonian algebroids generalize Lie algebras of
canonical transformations. We prove that the BRST operator for ${\cal A}^H$ is
cubic in the ghost fields as in the Lie algebra case. The Poisson sigma model
is a natural example of this construction. Canonical transformations of its
phase space define a Hamiltonian algebroid with the Lie brackets related to the
Poisson structure on the target space. We apply this scheme to analyze the
symmetries of generalized deformations of complex structures on Riemann curves
$\Si_{g,n}$ of genus $g $with $n$ marked points .We endow the space of local
$\GL$-opers with the Adler-Gelfand-Dikii (AGD) Poisson brackets. It allows us
to define a Hamiltonian algebroid over the phase space of $W_N$-gravity on
$\Si_{g,n}$. The sections of the algebroid are Volterra operators on
$\Si_{g,n}$ with the Lie brackets coming from the AGD bivector. The symplectic
reduction defines the finite-dimensional moduli space of $W_N$-gravity and in
particular the moduli space of the complex structures $\bp$ on $\Si_{g,n}$
deformed by the Volterra operators.
