||We study the scaling relations between gas-phase metallicity, stellar mass surface density (Σ*), star formation rate surface density (ΣSFR), and molecular gas surface density (ΣH2
) in local star-forming galaxies on scales of a kpc. We employ optical integral field spectroscopy from the Mapping Nearby Galaxies at Apache Point Observatory (MaNGA) survey, and ALMA data for a subset of MaNGA galaxies. We use partial correlation coefficients and Random Forest regression to determine the relative importance of local and global galactic properties in setting the gas-phase metallicity. We find that the local metallicity depends primarily on Σ* (the resolved mass–metallicity relation, rMZR), and has a secondary anticorrelation with ΣSFR (i.e. a spatially resolved version of the ‘Fundamental Metallicity Relation’, rFMR). We find that ΣH2
is less important than ΣSFR in determining the local metallicity. This result indicates that gas accretion, resulting in local metallicity dilution and local boosting of star formation, is unlikely to be the primary origin of the rFMR. The local metallicity depends also on the global properties of galaxies. We find a strong dependence on the total stellar mass (M*) and a weaker (inverse) dependence on the total SFR. The global metallicity scaling relations, therefore, do not simply stem out of their resolved counterparts; global properties and processes, such as the global gravitational potential well, galaxy-scale winds and global redistribution/mixing of metals, likely contribute to the local metallicity, in addition to local production and retention.