We investigate the relationship between stellar mass, metallicity and gas content for a magnitude- and volume-limited sample of 260 nearby late-type galaxies in different environments, from isolated galaxies to Virgo cluster members.We derive oxygen abundance estimates using new integrated, drift-scan optical spectroscopy and the base metallicity calibrations of Kewley & Ellison (2008, ApJ, 681, 1183). Combining these measurements with ultraviolet to near-infrared photometry and Hi 21 cm line observations, we examine the relations between stellar mass, metallicity, gas mass fraction and star formation rate. We find that, at fixed stellar mass, galaxies with lower gas fractions typically also possess higher oxygen abundances. We also observe a relationship between gas fraction and metal content, whereby gas-poor galaxies are typically more metal-rich, and demonstrate that the removal of gas from the outskirts of spirals may increase the observed average metallicity by ∼0.1 dex. Although some cluster galaxies are gas-deficient objects, statistically the stellar-mass metallicity relation is nearly invariant to the environment, in agreement with recent studies. These results indicate that internal evolutionary processes, rather than environmental effects, play a key role in shaping the stellar mass-metallicity relation. In addition, we present metallicity estimates based on observations of 478 nearby galaxies. © ESO 2013.