  Measuring the abundances of carbon and oxygen in exoplanet atmospheres is
considered a crucial avenue for unlocking the formation and evolution of
exoplanetary systems. Access to an exoplanet's chemical inventory requires
high-precision observations, often inferred from individual molecular
detections with low-resolution space-based and high-resolution ground-based
facilities. Here we report the medium-resolution (R$\sim$600) transmission
spectrum of an exoplanet atmosphere between 3-5 $\mu$m covering multiple
absorption features for the Saturn-mass exoplanet WASP-39b, obtained with JWST
NIRSpec G395H. Our observations achieve 1.46x photon precision, providing an
average transit depth uncertainty of 221 ppm per spectroscopic bin, and present
minimal impacts from systematic effects. We detect significant absorption from
CO$_2$ (28.5$\sigma$) and H$_2$O (21.5$\sigma$), and identify SO$_2$ as the
source of absorption at 4.1 $\mu$m (4.8$\sigma$). Best-fit atmospheric models
range between 3 and 10x solar metallicity, with sub-solar to solar C/O ratios.
These results, including the detection of SO$_2$, underscore the importance of
characterising the chemistry in exoplanet atmospheres, and showcase NIRSpec
G395H as an excellent mode for time series observations over this critical
wavelength range.
