  In this paper, we study the classical and quantum equivariant cohomology of
Nakajima quiver varieties for a general quiver Q. Using a geometric R-matrix
formalism, we construct a Hopf algebra Y_Q, the Yangian of Q, acting on the
cohomology of these varieties, and show several results about their basic
structure theory. We prove a formula for quantum multiplication by divisors in
terms of this Yangian action. The quantum connection can be identified with the
trigonometric Casimir connection for Y_Q; equivalently, the divisor operators
correspond to certain elements of Baxter subalgebras of Y_Q. A key role is
played by geometric shift operators which can be identified with the quantum KZ
difference connection.
  In the second part, we give an extended example of the general theory for
moduli spaces of sheaves on C^2, framed at infinity. Here, the Yangian action
is analyzed explicitly in terms of a free field realization; the corresponding
R-matrix is closely related to the reflection operator in Liouville field
theory. We show that divisor operators generate the quantum ring, which is
identified with the full Baxter subalgebras. As a corollary of our
construction, we obtain an action of the W-algebra W(gl(r)) on the equivariant
cohomology of rank $r$ moduli spaces, which implies certain conjectures of
Alday, Gaiotto, and Tachikawa.
