Optical spectroscopic measurements show that gas in dusty, starbursting galaxies known as ultraluminous infrared galaxies (ULIRGs) in the local Universe has a significantly lower metal content than that of gas in star-forming galaxies with similar masses. This low metal content has resulted in the claim that ULIRGs are primarily fuelled by metal-poor gas falling into those galaxy merger systems from large distances. Here we report a new set of gas-phase metal abundance measurements taken in local ULIRGs using emission lines at far-infrared wavelengths tracing oxygen and nitrogen. These new data show that ULIRGs lie on the fundamental metallicity relation determined by the stellar mass, metal abundance and star formation rate as the key observational parameters. Instead of metal-poor gas accretion, the new data suggest that the underabundance of metals derived from optical emission lines is probably due to heavy dust obscuration associated with the starburst. As dust-obscured, infrared-bright galaxies dominate the star formation rate density of the Universe during the peak epoch of star formation, we caution the use of rest-frame optical measurements alone to study the metal abundances of galaxies at redshifts of 2-3.