The Marine Biogeochemistry Library (MARBL) is a prognostic ocean biogeochemistry model that simulates marine ecosystem dynamics and the coupled cycles of carbon, nitrogen, phosphorus, iron, silicon, and oxygen. MARBL is a component of the Community Earth System Model (CESM); it supports flexible ecosystem configuration of multiple phytoplankton and zooplankton functional types; it is also portable, designed to interface with multiple ocean circulation models. Here, we present scientific documentation of MARBL, describe its configuration in CESM2 experiments included in the Coupled Model Intercomparison Project version 6 (CMIP6), and evaluate its performance against a number of observational datasets. The model simulates an air-sea CO2 flux and many aspects of the carbon cycle in good agreement with observations. However, the simulated integrated uptake of anthropogenic CO2 is weak, which we link to poor thermocline ventilation, a feature evident in simulated chlorofluorocarbon distributions. This also contributes to larger-than-observed oxygen minimum zones. Moreover, radiocarbon distributions show that the simulated circulation in the deep North Pacific is extremely sluggish, yielding extensive oxygen depletion and nutrient trapping at depth. Surface macronutrient biases are generally positive at low latitudes and negative at high latitudes. CESM2 simulates globally-integrated net primary production (NPP) of 48 Pg C yr-1 and particulate export flux at 100 m of 7.1 Pg C yr-1. The impacts of climate change include an increase in globally-integrated NPP, but substantial declines in the North Atlantic. Particulate export is projected to decline globally, attributable to decreasing export efficiency associated with changes in phytoplankton community composition.