  We describe the first three-dimensional simulation of the gravitational
collapse of a massive, rotating molecular cloud that includes heating by both
non-ionizing and ionizing radiation. We find that as the first protostars gain
sufficient mass to ionize the accretion flow, their H II regions are initially
gravitationally trapped, but soon begin to rapidly fluctuate between trapped
and extended states, in agreement with observations. Over time, the same
ultracompact H II region can expand anisotropically, contract again, and take
on any of the observed morphological classes. In their extended phases,
expanding H II regions drive bipolar neutral outflows characteristic of
high-mass star formation. The total lifetime of H II regions is given by the
global accretion timescale, rather than their short internal sound-crossing
time. The pressure of the hot, ionized gas does not terminate accretion.
Instead the final stellar mass is set by fragmentation-induced starvation.
Local gravitational instabilities in the accretion flow lead to the build-up of
a small cluster of stars, all with relatively high masses due to heating from
accretion radiation. These companions subsequently compete with the initial
high-mass star for the same common gas reservoir and limit its mass growth. Our
findings show that the most significant differences between the formation of
low-mass and high-mass stars are all explained as the result of rapid accretion
within a dense, gravitationally unstable, ionized flow.
