Soft X-ray absorption in excess of Galactic is observed in the afterglows of most gamma-ray bursts (GRBs), but the correct solution to its origin has not been arrived at after more than a decade of work, preventing its use as a powerful diagnostic tool. We resolve this long-standing problem and find that absorption by He in the GRB's host H II region is responsible for most of the absorption. We show that the X-ray absorbing column density () is correlated with both the neutral gas column density and with the optical afterglow's dust extinction (AV ). This correlation explains the connection between dark bursts and bursts with high values. From these correlations, we exclude an origin of the X-ray absorption which is not related to the host galaxy, i.e., the intergalactic medium or intervening absorbers are not responsible. We find that the correlation with the dust column has a strong redshift evolution, whereas the correlation with the neutral gas does not. From this, we conclude that the column density of the X-ray absorption is correlated with the total gas column density in the host galaxy rather than the metal column density, in spite of the fact that X-ray absorption is typically dominated by metals. The strong redshift evolution of is thus a reflection of the cosmic metallicity evolution of star-forming galaxies and we find it to be consistent with measurements of the redshift evolution of metallicities for GRB host galaxies. We conclude that the absorption of X-rays in GRB afterglows is caused by He in the H II region hosting the GRB. While dust is destroyed and metals are stripped of all of their electrons by the GRB to great distances, the abundance of He saturates the He-ionizing UV continuum much closer to the GRB, allowing it to remain in the neutral or singly-ionized state. Helium X-ray absorption explains the correlation with total gas, the lack of strong evolution with redshift, as well as the absence of dust, metal or hydrogen absorption features in the optical-UV spectra.