The unexpectedly high flux of cosmic ray positrons detected at Earth may originate from nearby astrophysical sources, dark matter, or unknown processes of cosmic-ray secondary production. We report the detection, using the HighAltitude Water Cherenkov Observatory (HAWC), of extended tera-electron volt gamma-ray emission coincident with the locations of two nearby middle-aged pulsars (Geminga and PSR B0656+14). The HAWC observations demonstrate that these pulsars are indeed local sources of accelerated leptons, but the measured tera-electron volt emission profile constrains the diffusion of particles away from these sources to be much slower than previously assumed. We demonstrate that the leptons emitted by these objects are therefore unlikely to be the origin of the excess positrons, which may have a more exotic origin.