The interplay between the quasi 1-dimensional CuO-chains and the 2-dimensional CuO2 planes of YBa(2)Cu(3)O(6+x) (YBCO) has been in focus for a long time. Although the CuO-chains are known to be important as charge reservoirs that enable superconductivity for a range of oxygen doping levels in YBCO, the understanding of the dynamics of its temperature-driven metal-superconductor transition (MST) remains a challenge. We present a combined study using x-ray absorption spectroscopy and resonant inelastic x-ray scattering (RIXS) revealing how a reconstruction of the apical O(4)-derived interplanar orbitals during the MST of optimally doped YBCO leads to substantial hole-transfer from the chains into the planes, i.e. self-doping. Our ionic model calculations show that localized divalent charge-transfer configurations are expected to be abundant in the chains of YBCO. While these indeed appear in the RIXS spectra from YBCO in the normal, metallic, state, they are largely suppressed in the superconducting state and, instead, signatures of Cu trivalent charge-transfer configurations in the planes become enhanced. In the quest for understanding the fundamental mechanism for high-Tc-superconductivity (HTSC) in perovskite cuprate materials, the observation of such an interplanar self-doping process in YBCO opens a unique novel channel for studying the dynamics of HTSC.