We study the mass-metallicity relation of galaxies in pairs and in isolation taken from the SDSS-DR4 using the stellar masses and oxygen abundances derived by Tremonti et al. (2004). Close galaxy pairs, defined by projected separation r_p < 25kpc/h and radial velocity Delta_V < 350 km/s, are morphologically classified according to the strength of the interaction signs. We find that only for pairs showing signs of strong interactions, the mass-metallicity relation differs significantly from that of galaxies in isolation. In such pairs, the mean gas-phase oxygen abundances of galaxies with low stellar masses (Mstar ~< 10^9 Msun/h) exhibit an excess of 0.2 dex. Conversely, at larger masses (Mstar >~ 10^10 Msun/h) galaxies have a systematically lower metallicity, although with a smaller difference (-0.05 dex). Similar trends are obtained if g-band magnitudes are used instead of stellar masses. In minor interactions, we find that the less massive member is systematically enriched, while a galaxy in interaction with a comparable stellar mass companion shows a metallicity decrement with respect to galaxies in isolation. We argue that metal-rich starbursts triggered by a more massive component, and inflows of low metallicity gas induced by comparable or less massive companion galaxies, provide a natural scenario to explain our findings.