White dwarfs have frozen in magnetic fields ranging from below the measurable limit of about 3×103 to 109 G. White dwarfs with surface magnetic fields in excess of 1 MG are found as isolated single stars and relatively more often in magnetic cataclysmic variables. Some 1253 white dwarfs with a detached low-mass main-sequence companion have been identified in the Sloan Digital Sky Survey (SDSS) but none of these shows sufficient evidence for Zeeman splitting of hydrogen lines for a magnetic field in excess of 1 MG. If such high magnetic fields in white dwarfs result from the isolated evolution of a single star then there should be the same fraction of high field white dwarfs among this SDSS binary sample as among single stars. Thus, we deduce that the origin of such high magnetic fields must be intimately tied to the formation of cataclysmic variables (CVs). The formation of a CV must involve orbital shrinkage from giant star to main-sequence star dimensions. It is believed that this shrinkage occurs as the low-mass companion and the white dwarf spiral together inside a common envelope. CVs emerge as very close but detached binary stars that are then brought together by magnetic braking or gravitational radiation. We propose that the smaller the orbital separation at the end of the common envelope phase, the stronger the magnetic field. The magnetic cataclysmic variables (MCVs) originate from those common envelope systems that almost merge. Those common envelope systems that do merge are the progenitors of the single high field white dwarfs. Thus all highly magnetic white dwarfs, be they single stars or the components of MCVs, have a binary origin. This accounts for the relative dearth of single white dwarfs with fields of 104–106 G. Such intermediate-field white dwarfs are found preferentially in cataclysmic variables. The bias towards higher masses for highly magnetic white dwarfs is expected if a fraction of these form when two degenerate cores merge in a common envelope. From the space density of single highly magnetic white dwarfs we estimate that about three times as many common envelope events lead to a merged core as to a cataclysmic variable.