The development of next generation perovskite-based optoelectronic devices relies critically on the understanding of the interaction between charge carriers and the polar lattice in out-of-equilibrium conditions. While it has become increasingly evident for CsPbBr3 perovskites that the Pb-Br framework flexibility plays a key role in their light-activated functionality, the corresponding local structural rearrangement has not yet been unambiguously identified. In this work, we demonstrate that the photoinduced lattice changes in the system are due to a specific polaronic distortion, associated with the activation of a longitudinal optical phonon mode at 18 meV by electron-phonon coupling, and we quantify the associated structural changes with atomic-level precision. Key to this achievement is the combination of time-resolved and temperature-dependent studies at Br K-edge and Pb L3-edge X-ray absorption with refined ab-initio simulations, which fully account for the screened core-hole final state effects on the X-ray absorption spectra. From the temporal kinetics, we show that carrier recombination reversibly unlocks the structural deformation at both Br and Pb sites. The comparison with the temperature-dependent XAS results rules out thermal effects as the primary source of distortion of the Pb-Br bonding motif during photoexcitation. Our work provides a comprehensive description of the CsPbBr3 perovskites photophysics, offering novel insights on the light-induced response of the system and its exceptional optoelectronic properties.