Segments of flat subduction are recognized in subduction zones, but little is known about the behavior of slabs along the edges of flat slab segments. Well-constrained earthquake data from the northern edge of the Peru flat slab segment reveal that the subducting Nazca slab is more contorted than previously assumed, with a prominent tear developed along a lateral ramp that bounds the Peruvian flat slab beneath southern Ecuador. The slab geometry and associated tear are spatially linked to Sumaco volcano ∼100 km east of the arc front. Sumaco mafic lavas are ultrapotassic, enriched in incompatible elements, and show little evidence for crustal assimilation. These geochemical signatures are consistent with low-degree (≤3%) melting of an upper mantle source comprising depleted mid-oceanic ridge basalt (MORB) mantle within the spinel stability field, and metasomatism of the source by melts derived from the basaltic portion of the slab within the garnet stability field (>80 km depth). We propose that focused melting at the slab edge was enabled by the combination of tearing and the generation of poloidal mantle flow in the proximity of the tear. A possible explanation for this process is the opening of a trapdoor-style tear, which induced a poloidal mantle flow by the gravitational foundering of the relatively old and dense edge of the flat slab segment.