In this work, we study the intersection cohomology of Siegel modular varieties. The goal is to express the trace of a Hecke operator composed with a power of the Frobenius endomorphism (at a good place) on this cohomology in terms of the geometric side of Arthur’s invariant trace formula for well-chosen test functions. Our main tools are the results of Kottwitz about the contribution of the cohomology with compact support and about the stabilization of the trace formula, Arthur’s L2 trace formula and the fixed point formula of Morel [Complexes pondérés sur les compactifications de Baily–Borel. Le cas des variétés de Siegel, J. Amer. Math. Soc. 21 (2008), 23–61]. We ‘stabilize’ this last formula, i.e. express it as a sum of stable distributions on the general symplectic groups and its endoscopic groups, and obtain the formula conjectured by Kottwitz in [Shimura varieties and λ-adic representations, in Automorphic forms, Shimura varieties and L-functions, Part I, Perspectives in Mathematics, vol. 10 (Academic Press, San Diego, CA, 1990), 161–209]. Applications of the results of this article have already been given by Kottwitz, assuming Arthur’s conjectures. Here, we give weaker unconditional applications in the cases of the groups GSp4 and GSp6.