Cadmium telluride, CdTe, is now firmly established as the basis for the market-leading thin-film solar-cell technology. With laboratory efficiencies approaching 20 per cent, the research and development targets for CdTe are to reduce the cost of power generation further to less than half a US dollar per watt (ref. 2) and to minimize the environmental impact. A central part of the manufacturing process involves doping the polycrystalline thin-film CdTe with CdCl2. This acts to form the photovoltaic junction at the CdTe/CdS interface and to passivate the grain boundaries, making it essential in achieving high device efficiencies. However, although such doping has been almost ubiquitous since the development of this processing route over 25 years ago, CdCl2 has two severe disadvantages; it is both expensive (about 30 cents per gram) and a water-soluble source of toxic cadmium ions, presenting a risk to both operators and the environment during manufacture. Here we demonstrate that solar cells prepared using MgCl2, which is non-toxic and costs less than a cent per gram, have efficiencies (around 13%) identical to those of a CdCl2-processed control group. They have similar hole densities in the active layer (9 × 10(14) cm(-3)) and comparable impurity profiles for Cl and O, these elements being important p-type dopants for CdTe thin films. Contrary to expectation, CdCl2-processed and MgCl2-processed solar cells contain similar concentrations of Mg; this is because of Mg out-diffusion from the soda-lime glass substrates and is not disadvantageous to device performance. However, treatment with other low-cost chlorides such as NaCl, KCl and MnCl2 leads to the introduction of electrically active impurities that do compromise device performance. Our results demonstrate that CdCl2 may simply be replaced directly with MgCl2 in the existing fabrication process, thus both minimizing the environmental risk and reducing the cost of CdTe solar-cell production.