The efficiency with which polymeric semiconductors can be chemically doped—and the charge carrier densities that can thereby be achieved—is determined primarily by the electrochemical redox potential between the π-conjugated polymer and the dopant species1,2. Thus, matching the electron affinity of one with the ionization potential of the other can allow effective doping3,4. Here we describe a different process—which we term ‘anion exchange’—that might offer improved doping levels. This process is mediated by an ionic liquid solvent and can be pictured as the effective instantaneous exchange of a conventional small p-type dopant anion with a second anion provided by an ionic liquid. The introduction of optimized ionic salt (the ionic liquid solvent) into a conventional binary donor–acceptor system can overcome the redox potential limitations described by Marcus theory5, and allows an anion-exchange efficiency of nearly 100 per cent. As a result, doping levels of up to almost one charge per monomer unit can be achieved. This demonstration of increased doping levels, increased stability and excellent transport properties shows that anion-exchange doping, which can use an almost infinite selection of ionic salts, could be a powerful tool for the realization of advanced molecular electronics.