We present the results of resonant x-ray scattering experiments on KCuF 3 . Structurally forbidden reflections, corresponding to magnetic and 3d-orbital long-range order, have been observed. Integrated intensities have been measured as a function of incident energy, polarization, azimuthal angle, and temperature. By means of ab initio local spin density approximation ͑LSDA͒ and local spin density approximation with on-site Coulomb interaction ͑LSDAϩU͒ calculations we determine the electronic structure of KCuF 3 and obtain the resonant x-ray scattering spectrum at the Cu K edge, which shows good agreement with the experimental data. Orbital and spin degrees of freedom are strongly coupled, and the temperature dependence of the intensity of orbital Bragg peaks reveals a correlation between magnetic and orbital order parameters.