We report VLT-ISAAC and Keck-NIRSPEC near-infrared spectroscopy for a sample of 30 0.47<z<0.92 CFRS galaxies and five [OII]-selected, M_B,AB<-21.5, z~1.4 galaxies. We have measured Halpha and [NII] line fluxes for the CFRS galaxies which have [OII], Hbeta and [OIII] line fluxes available from optical spectroscopy. For the z~1.4 objects we measured Hbeta and [OIII] emission line fluxes from J-band spectra, and Halpha line fluxes plus upper limits for [NII] fluxes from H-band spectra. We derive the extinction and oxygen abundances for the sample using a method based on a set of ionisation parameter and oxygen abundance diagnostics, simultaneously fitting the [OII], Hbeta, [OIII], Halpha and [NII] line fluxes. Our most salient conclusions are: a) the source of gas ionisation in the 30 CFRS and in all z~1.4 galaxies is not due to AGN activity; b) about one third of the 0.47<z<0.92 CFRS galaxies in our sample have substantially lower metallicities than local galaxies with similar luminosities and star formation rates; c) comparison with a chemical evolution model indicates that these low metallicity galaxies are unlikely to be the progenitors of metal-poor dwarf galaxies at z~0, but more likely the progenitors of massive spirals; d) the z~1.4 galaxies are characterized by the high [OIII]/[OII] line ratios, low extinction and low metallicity that are typical of lower luminosity CADIS galaxies at 0.4<z<0.7, and of more luminous Lyman Break Galaxies at z~3.1, but not seen in CFRS galaxies at 0.4<z<1.0; e) the properties of the z~1.4 galaxies suggest that the period of rapid chemical evolution takes place progressively in lower mass systems as the universe ages, and thus provides further support for a downsizing picture of galaxy formation, at least from z~1.4 to today.