We report the observation of a magnetic polarization of the O,$2p$-states in YMn$_2$O$_5$ through the use of soft X-ray resonant scattering at the oxygen $K$-edge. Remarkably, we find that the temperature dependence of the integrated intensity of this signal closely follows the macroscopic electric polarization, and hence is proportional to the ferroelectric order parameter. This is in contrast to the temperature dependence observed at the Mn,$L_3$-edge, which reflects the Mn magnetic order parameter. First principle calculations provide a microscopic understanding of these results and show that a spin-dependent hybridization of O,$2p$- and Mn, 3d-states results in a purely electronic contribution to the ferroelectric polarization, which can exist in the absence of lattice distortions.