A special case of the geometric Langlands correspondence is given by the relationship between solutions of the Bethe ansatz equations for the Gaudin model and opers - connections on the projective line with extra structure. In this paper, we describe a deformation of this correspondence for $SL(N)$. We introduce a difference equation version of opers called $q$-opers and prove a $q$-Langlands correspondence between nondegenerate solutions of the Bethe ansatz equations for the XXZ model and nondegenerate twisted $q$-opers with regular singularities on the projective line. We show that the quantum/classical duality between the XXZ spin chain and the trigonometric Ruijsenaars-Schneider model may be viewed as a special case of the $q$-Langlands correspondence. We also describe an application of $q$-opers to the equivariant quantum $K$-theory of the cotangent bundles to partial flag varieties.