This paper presents a model which yields examples of stable vortices in a continuously stratified rotating fluid, thus providing a possible explanation of the observed longevity of oceanic eddies. The model is based on two assumptions. Firstly, the ocean comprises a thin upper (active) layer and a thick lower (passive) one, with large and small vertical gradients of density, respectively. Secondly, the Rossby number is small, justifying the use of the geostrophic and quasi-geostrophic approximations for the active and passive layers (the two are treated differently because the vortex-induced displacement of the isopycnal surfaces is comparable to the depth of the active layer, but is much smaller than that of the passive one). Using the asymptotic equations derived on the basis of the above assumptions, we prove a stability criterion and thus identify a class of stable vortex profiles. This class is much wider than the one following from the standard requirement that the potential vorticity be monotonic in the whole bulk of the fluid.