The observed surface dynamics of Jupiter and Saturn are dominated by a banded system of fierce zonal winds. The depth of these winds remains unclear but they are thought to be confined to the very outer envelopes where hydrogen remains molecular and the electrical conductivity is small. The dynamo maintaining the dipole-dominated magnetic fields of both gas giants, on the other hand, likely operates in the deeper interior where hydrogen assumes a metallic state.Here, we present numerical simulations that attempt to model both the zonal winds and the interior dynamo action in an integrated approach. Using the anelastic version of the MHD code MagIC, we explore the effects of density stratification and radial electrical conductivity variations. The electrical conductivity is mostly assumed to remain constant in the thicker inner metallic region and it decays exponentially towards the outer boundary throughout the molecular envelope.Our results show that the combination of a stronger density stratification and a weaker conducting outer layer is essential for reconciling dipole dominated dynamo action and a fierce equatorial zonal jet. Previous simulations with homogeneous electrical conductivity show that both are mutually exclusive, with solutions either having strong zonal winds and multipolar magnetic fields or weak zonal winds and dipole-dominated magnetic fields. All jets tend to be geostrophic and therefore reach right through the convective shell in our simulations.The particular setup explored here allows a strong equatorial jet to remain confined to the weaker conducting outer region where it does not interfere with the deeper seated dynamo action. The flanking mid to high latitude jets, on the other hand, have to remain faint to yield a strongly dipolar magnetic field. The fiercer jets on Jupiter and Saturn only seem compatible with the observed dipolar fields when they remain confined to a weaker conducting outer layer.