Context : Aims : We want to derive the mass-metallicity relation of star-forming galaxies up to z \sim 0.9 , using data from the VIMOS VLT Deep Survey . The mass-metallicity relation is commonly understood as the relation between the stellar mass and the gas-phase oxygen abundance . Methods : Automatic measurement of emission-line fluxes and equivalent widths have been performed on the full spectroscopic sample of the VIMOS VLT Deep Survey . This sample is divided into two sub-samples depending on the apparent magnitude selection : wide ( I _ { \mathrm { AB } } < 22.5 ) and deep ( I _ { \mathrm { AB } } < 24 ) . These two samples span two different ranges of stellar masses . Emission-line galaxies have been separated into star-forming galaxies and active galactic nuclei using emission line ratios . For the star-forming galaxies the emission line ratios have also been used to estimate gas-phase oxygen abundance , using empirical calibrations renormalized in order to give consistent results at low and high redshifts . The stellar masses have been estimated by fitting the whole spectral energy distributions with a set of stellar population synthesis models . Results : We assume at first order that the shape of the mass-metallicity relation remains constant with redshift . Then we find a stronger metallicity evolution in the wide sample as compared to the deep sample . We thus conclude that the mass-metallicity relation is flatter at higher redshift . At z \sim 0.77 , galaxies at 10 ^ { 9.4 } solar masses have -0.18 dex lower metallicities than galaxies of similar masses in the local universe , while galaxies at 10 ^ { 10.2 } solar masses have -0.28 dex lower metallicities . By comparing the mass-metallicity and luminosity-metallicity relations , we also find an evolution in mass-to-light ratios : galaxies at higher redshifts being more active . The observed flattening of the mass-metallicity relation at high redshift is analyzed as an evidence in favor of the open-closed model . Conclusions :