Star-forming galaxies display a close relation among stellar mass, metallicity and star-formation rate (or molecular-gas mass). This is known as the fundamental metallicity relation (FMR) (or molecular-gas FMR), and it has a profound implication on models of galaxy evolution. However, there still remains a significant residual scatter around the FMR. We show here that a fourth parameter, the surface density of stellar mass, reduces the dispersion around the molecular-gas FMR. In a principal component analysis of 29 physical parameters of 41,338 star-forming galaxies, the surface density of stellar mass is found to be the fourth most important parameter. The new four-dimensional (4D) fundamental relation forms a tighter hypersurface that reduces the metallicity dispersion to 50% of that of the molecular-gas FMR. We suggest that future analyses and models of galaxy evolution should consider the FMR in a 4D space that includes surface density. The dilution time scale of gas inflow and the star-formation efficiency could explain the observational dependence on surface density of stellar mass. AKARI is expected to play an important role in shedding light on the infrared properties of the new 4D FMR.