Ultra-wideband, three-dimensional (3D) imaging spectrometry in the millimeter–submillimeter (mm–submm) band is an essential tool for uncovering the dust-enshrouded portion of the cosmic history of star formation and galaxy evolution1–3. However, it is challenging to scale up conventional coherent heterodyne receivers4 or free-space diffraction techniques5 to sufficient bandwidths (≥1 octave) and numbers of spatial pixels2,3 (>102). Here, we present the design and astronomical spectra of an intrinsically scalable, integrated superconducting spectrometer6, which covers 332–377 GHz with a spectral resolution of F/ΔF ~ 380. It combines the multiplexing advantage of microwave kinetic inductance detectors (MKIDs)7 with planar superconducting filters for dispersing the signal in a single, small superconducting integrated circuit. We demonstrate the two key applications for an instrument of this type: as an efficient redshift machine and as a fast multi-line spectral mapper of extended areas. The line detection sensitivity is in excellent agreement with the instrument design and laboratory performance, reaching the atmospheric foreground photon noise limit on-sky. The design can be scaled to bandwidths in excess of an octave, spectral resolution up to a few thousand and frequencies up to ~1.1 THz. The miniature chip footprint of a few cm2 allows for compact multi-pixel spectral imagers, which would enable spectroscopic direct imaging and large-volume spectroscopic surveys that are several orders of magnitude faster than what is currently possible1–3.