A first-principles investigation of Si 2p core-level shifts at the Si(001)-SiO2 interface is presented. We introduce several relaxed interface models obtained by attaching different crystalline forms of SiO2 to Si(001). These model structures contain the minimal transition region required to accommodate the three intermediate oxidation states of silicon, in accord with photoemission experiments. The bond density mismatch is fixed by saturating all the bonds, as required by electrical measurements, Calculated core shifts are primarily affected by the number of nearest-neighbor oxygen atoms, showing a linear dependence. This result confirms the traditional interpretation of the photoemission spectra based on a charge-transfer model. Core relaxation plays a significant role accounting for more than 50% of the total shifts. The shifts are found to be essentially insensitive to second and further neighbors in the structure. Structural deformations, such as those implied by the distribution of Si-O bond lengths in a-SiO2, yield distributions of core-level shifts that an too small to account for the observed width of the photoemission peaks. In the oxide, we observe a spatial dependence of the Si+4 shifts with distance from the interface plane. We relate this behavior to the dielectric discontinuity at the interface and suggest that this effect explains the shift of the Si+4 with oxide thickness, observed in photoemission experiments.