Context. We present the first spectroscopic observations of Ganymede by the James Webb Space Telescope undertaken in August 2022 as part of the proposal “ERS observations of the Jovian system as a demonstration of JWST’s capabilities for Solar System science”. Aims. We aimed to investigate the composition and thermal properties of the surface, and to study the relationships of ice and non-water-ice materials and their distribution. Methods. NIRSpec IFU (2.9–5.3 μm) and MIRI MRS (4.9–28.5 μm) observations were performed on both the leading and trailing hemispheres of Ganymede, with a spectral resolution of ~2700 and a spatial sampling of 0.1 to 0.17″ (while the Ganymede size was ~1.68″). We characterized the spectral signatures and their spatial distribution on the surface. The distribution of brightness temperatures was analyzed with standard thermophysical modeling including surface roughness. Results. Reflectance spectra show signatures of water ice, CO2, and H2O2. An absorption feature at 5.9 μm, with a shoulder at 6.5 μm, is revealed, and is tentatively assigned to sulfuric acid hydrates. The CO2 4.26-μm band shows latitudinal and longitudinal variations in depth, shape, and position over the two hemispheres, unveiling different CO2 physical states. In the ice-rich polar regions, which are the most exposed to Jupiter’s plasma irradiation, the CO2 band is redshifted with respect to other terrains. In the boreal region of the leading hemisphere, the CO2 band is dominated by a high wavelength component at ~4.27 μm, consistent with CO2 trapped in amorphous water ice. At equatorial latitudes (and especially on dark terrains), the observed band is broader and shifted toward the blue, suggesting CO2 adsorbed on non-icy materials, such as minerals or salts. Maps of the H2O Fresnel peak area correlate with Bond albedo maps and follow the distribution of water ice inferred from H2O absorption bands. Amorphous ice is detected in the ice-rich polar regions, and is especially abundant on the northern polar cap of the leading hemisphere. Leading and trailing polar regions exhibit different H2O, CO2, and H2O2 spectral properties. However, in both hemispheres the north polar cap ice appears to be more processed than the south polar cap. A longitudinal modification of the H2O ice molecular structure and/or nanometer- and micrometer-scale texture, of diurnal or geographic origin, is observed in both hemispheres. Ice frost is tentatively observed on the morning limb of the trailing hemisphere, which possibly formed during the night from the recondensation of water subliming from the warmer subsurface. Reflectance spectra of the dark terrains are compatible with the presence of Na- and Mg-sulfate salts, sulfuric acid hydrates, and possibly phyllosilicates mixed with fine-grained opaque minerals, with a highly porous texture. Latitude and local time variations of the brightness temperatures indicate a rough surface with mean slope angles of 15°–25° and a low thermal inertia Γ = 20 − 40 J m−2 s−0.5 K−1, consistent with a porous surface, with no obvious difference between the leading and trailing sides.