The measurement of the cosmic microwave background has strongly constrained the cosmological parameters of the Universe1. When the measured density of baryons (ordinary matter) is combined with standard Big Bang nucleosynthesis calculations2,3, the amounts of hydrogen, helium and lithium produced shortly after the Big Bang can be predicted with unprecedented precision1,4. The predicted primordial lithium abundance is a factor of two to three higher than the value measured in the atmospheres of old stars5,6. With estimated errors of 10 to 25%, this cosmological lithium discrepancy seriously challenges our understanding of stellar physics, Big Bang nucleosynthesis or both. Certain modifications to nucleosynthesis have been proposed7, but found experimentally not to be viable8. Diffusion theory, however, predicts atmospheric abundances of stars to vary with time9, which offers a possible explanation of the discrepancy. Here we report spectroscopic observations of stars in the metal-poor globular cluster NGC6397 that reveal trends of atmospheric abundance with evolutionary stage for various elements. These element-specific trends are reproduced by stellar-evolution models with diffusion and turbulent mixing10. We thus conclude that diffusion is predominantly responsible for the low apparent stellar lithium abundance in the atmospheres of old stars by transporting the lithium deep into the star.