We present results from x-ray diffraction experiments and density functional theory calculations which provide a fully consistent picture of the high-pressure phosphorus-IV phase (P-IV). P-IV has an incommensurately-modulated crystal structure described by the four-dimensional superspace group Cmmm(00 gamma)s00. Electronic structure calculations using a three-dimensional commensurate approximant to this structure give excellent agreement with experiment for the structural parameters and their variation with pressure. Density functional perturbation theory shows a phonon instability at the incommensurate wave vector, related to the opening of a pseudogap at the Fermi surface, showing that the atomic motions comprising the incommensuration occur to eliminate Fermi-surface nesting. Unusually, the pseudogap opens not at the incommensurate wave vector (00 gamma) itself, but at two larger wave vectors corresponding to strong reflections in the diffraction pattern.