An analytical study of the stability of perturbations propagating along a nonuniform ion drift, which includes both the ExB and the ion diamagnetic drifts, in a magnetohydrodynamic plasma immersed in a nonuniform magnetic field, is presented. The behavior of stable and unstable modes is studied in the case when the shear flow is described by an analytical tanh(x)-type ion drift. A threshold for the wave-number is obtained analytically and a perturbative analysis is performed around the threshold. It is shown that modes with wave-numbers that are less than the threshold gain energy from the shear flow and are therefore unstable, which is in agreement with well-known instability criteria obtained numerically. (C) 2002 American Institute of Physics.