Landau–Fermi liquid theory, with its pivotal assertion that electrons in metals can be simply understood as independent particles with effective masses replacing the free electron mass, has been astonishingly successful. This is true despite the Coulomb interactions an electron experiences from the host crystal lattice, lattice defects and the other 1022 cm-3 electrons. An important extension to the theory accounts for the behaviour of doped semiconductors1, 2. Because little in the vast literature on materials contradicts Fermi liquid theory and its extensions, exceptions have attracted great attention, and they include the high-temperature superconductors3, silicon-based field-effect transistors that host two-dimensional metals4, and certain rare-earth compounds at the threshold of magnetism5, 6, 7, 8. The origin of the non-Fermi liquid behaviour in all of these systems remains controversial. Here we report that an entirely different and exceedingly simple class of materials—doped small-bandgap semiconductors near a metal–insulator transition—can also display a non-Fermi liquid state. Remarkably, a modest magnetic field functions as a switch which restores the ordinary disordered Fermi liquid. Our data suggest that we have found a physical realization of the only mathematically rigorous route to a non-Fermi liquid, namely the 'undercompensated Kondo effect', where there are too few mobile electrons to compensate for the spins of unpaired electrons localized on impurity atoms9, 10, 11, 12.