Aims. The stability of the dissipative Taylor-Couette flow with a stable axial density stratification and a prescribed azimuthal magnetic field is considered. Methods. Global nonaxisymmetric solutions of the linearized MHD equations with toroidal magnetic field, density stratification, and differential rotation are found for both insulating and conducting cylinders. Results. Hydrodynamic calculations for various gap widths show that flat rotation laws such as the Kepler rotation are always unstable against SRI. Quasigalactic rotation laws, however, are stable for wide gaps. The influence of a current-free toroidal magnetic field on SRI strongly depends on the magnetic Prandtl number Pm: SRI is supported by Pm > 1 and it is suppressed by Pm < ∼ 1. For rotation laws that are too flat, when the hydrodynamic SRI ceases, a smooth transition exists to the instability that the toroidal magnetic field produces in combination with the differential rotation. For the first time this nonaxisymmetric azimuthal magnetorotational instability (AMRI) has been computed in the presence of an axial density gradient. If the magnetic field between the cylinders is not current-free, then the Tayler instability occurs, too. The transition from the nonmagnetic centrifugal instability to the magnetic Tayler instability in the presence of differential rotation and density stratification proves to be complex. Most spectacular is the "ballooning" of the stability domain by the density stratification: already a small rotation stabilizes magnetic fields against the Tayler instability. An azimuthal component of the electromotive force u × B for the instability only exists for density-stratified flows. The related α-effect for magnetic-influenced SRI with Kepler rotation appears to be positive for negative dρ/dz < 0.