Context. The long-period, highly eccentric O-star binary 9 Sgr, known for its non-thermal radio emission and its relatively bright X-ray emission, went through its periastron in 2013. Aims. Such an event can be used to observationally test the predictions of the theory of colliding stellar winds over a broad range of wavelengths. Methods. We conducted a multi-wavelength monitoring campaign of 9 Sgr around the 2013 periastron. In this paper, we focus on X-ray observations and optical spectroscopy. Results. The optical spectra allow us to revisit the orbital solution of 9 Sgr and to refine its orbital period to 9.1 years. The X-ray flux is maximum at periastron over all energy bands, but with clear differences as a function of energy. The largest variations are observed at energies above 2 keV, whilst the spectrum in the soft band (0.5−1.0 keV) remains mostly unchanged, indicating that it arises far from the collision region, in the inner winds of the individual components. The level of the hard emission at periastron clearly deviates from the 1/r relation expected for an adiabatic wind-interaction zone, whilst this relation seems to hold at the other phases that are covered by our observations. The spectra taken at phase 0.946 reveal a clear Fe xxv line at 6.7 keV, but no such line is detected at periastron (φ = 0.000), although a simple model predicts a strong line that should be easily visible in the data. Conclusions. The peculiarities of the X-ray spectrum of 9 Sgr could reflect the effect of radiative inhibition as well as a phasedependent efficiency of particle acceleration on the shock properties.