Lenses for precision electron optics are mainly magnetic, requiring large cylinders of soft iron to focus an electron beam. Such lenses can only be convergent1, and so suffer from spherical aberration. Electrostatic lenses are sometimes used, but tend to be even more cumbersome. The advent of high-brightness electron guns for scanning transmission electron microscopy has made it possible to use the resulting tightly focused electron beams to drill holes a few nanometres in size and of controlled depth in some inorganic thin films2,3,4,5: such patterned structures can then be used to manipulate the phase of an electron wave in a manner analogous to light optics6,7. Here we use this approach to fabricate compact solid-state ‘pixelated’ Fresnel lenses for electron optics. These lenses, which can be convergent or divergent, are not expected to compete with conventional magnetic lenses in most applications (such as microscopy), but may find a niche in electron-beam lithography.