  We investigate the evolution of galaxy gas-phase metallicity (O/H) over the
range $z=0-3.3$ using samples of $\sim300$ galaxies at $z\sim2.3$ and $\sim150$
galaxies at $z\sim3.3$ from the MOSDEF survey. This analysis crucially utilizes
different metallicity calibrations at $z\sim0$ and $z>1$ to account for
evolving ISM conditions. We find significant correlations between O/H and
stellar mass ($M_*$) at $z\sim2.3$ and $z\sim3.3$. The low-mass power law slope
of the mass-metallicity relation is remarkably invariant over $z=0-3.3$, such
that $\textrm{O/H}\propto M_*^{0.30}$ at all redshifts in this range. At fixed
$M_*$, O/H decreases with increasing redshift as dlog(O/H)/d$z=-0.11\pm0.02$.
We find no evidence that the fundamental metallicity relation between $M_*$,
O/H, and star-formation rate (SFR) evolves out to $z\sim3.3$, with galaxies at
$z\sim2.3-3.3$ having O/H within 0.04~dex of local galaxies matched in $M_*$
and SFR on average. We employ analytic chemical evolution models to place
constraints on the mass and metal loading factors of galactic outflows. The
efficiency of metal removal increases toward lower $M_*$ at fixed redshift, and
toward higher redshift at fixed $M_*$. These models suggest that the slope of
the mass-metallicity relation is set by the scaling of the metal loading factor
of outflows with $M_*$, not by the change in gas fraction as a function of
$M_*$. The evolution toward lower O/H at fixed $M_*$ with increasing redshift
is driven by both higher gas fraction (leading to stronger dilution of ISM
metals) and higher metal removal efficiency, with models suggesting that both
effects contribute approximately equally to the observed evolution. These
results suggest that the processes governing the smooth baryonic growth of
galaxies via gas flows and star formation hold in the same form over at least
the past 12~Gyr.
