Electricity produced by cadmium telluride (CdTe) photovoltaic modules is the lowest-cost electricity in the solar industry, and now undercuts fossil fuel-based sources in many regions of the world. This is due to recent efficiency gains brought about by alloying selenium into the CdTe absorber, which has taken cell efficiency from 19.5% to its current record of 22.1%. Although the addition of selenium is known to reduce the bandgap of the absorber material, and hence increase the cell short-circuit current, this effect alone does not explain the performance improvement. Here, by means of cathodoluminescence and secondary ion mass spectrometry, we show that selenium enables higher luminescence efficiency and longer diffusion lengths in the alloyed material, indicating that selenium passivates critical defects in the bulk of the absorber layer. This passivation effect explains the record-breaking performance of selenium-alloyed CdTe devices, and provides a route for further efficiency improvement that can result in even lower costs for solar-generated electricity.