We determine the local metallicity of the ionized gas for more than $9.2times 10^5$ star forming regions (spaxels) located in 1023 nearby galaxies included in the SDSS-IV MaNGA IFU survey. We use the dust extinction derived from the Balmer decrement and stellar template fitting in each spaxel to estimate the local gas and stellar mass densities, respectively. We also use the measured rotation curves to determine the local escape velocity ($mathrm{V_{esc}}$). We have then analyze the relationships between the local metallicity and both the local gas fraction ($mu$) and $mathrm{V_{esc}}$. We find that metallicity decreases with both increasing $mu$ and decreasing $mathrm{V_{esc}}$. By examining the residuals in these relations we show that the gas fraction plays a more primary role in the local chemical enrichment than $mathrm{V_{esc}}$. We show that the gas-regulator model of chemical evolution provides a reasonable explanation of the metallicity on local scales. The best-fit parameters for this model are consistent with metal loss caused by momentum-driven galactic outflows. We also argue that both the gas fraction and local escape velocity are connected to the local stellar surface density, which in turn is a tracer of the epoch at which the dominant local stellar population formed