  We systematically measure the gas-phase metallicities and the
mass-metallicity relation of a large sample of local active galaxies for the
first time. Observed emission-line fluxes from the Sloan Digital Sky Survey
(SDSS) are compared to a four-dimensional grid of photoionization models using
the Bayesian parameter estimation code NebulaBayes. For the first time we take
into account arbitrary mixing between HII region and narrow-line region (NLR)
emission, and the models are also varied with metallicity, ionization parameter
in the NLR, and the gas pressure. The active galactic nucleus (AGN) oxygen
abundance is found to increase by $\Delta {\rm O/H} \sim 0.1$ dex as a function
of host galaxy stellar mass over the range $10.1 < \log M_* / M_\odot < 11.3$.
We also measure the metallicity and ionization parameter of 231000 star-forming
galaxies for comparison with the sample of 7670 Seyfert 2 galaxies. A
systematic offset in oxygen abundance of 0.09 dex is observed between the
mass-metallicity relations of the star-forming and active galaxies. We
investigate potential causes of the offset, including sample selection and the
treatment in the models of diffuse ionized gas, pressure, and ionization
parameter. We cannot identify the major cause(s), but suspect contributions due
to deficiencies in modeling the ionizing spectra and the treatment of dust
physics. Optical diagnostic diagrams are presented with the star-forming and
Seyfert data colored by the inferred oxygen abundance, ionization parameter and
gas pressure, clearly illustrating the trends in these quantities.
