Slip on a subduction megathrust can be seismic or aseismic, with the two modes of slip complementing each other in time and space to accommodate the long-term plate motions. Although slip is almost purely aseismic at depths greater than about 40 km, heterogeneous surface strain suggests that both modes of slip occur at shallower depths, with aseismic slip resulting from steady or transient creep in the interseismic and postseismic periods. Thus, active faults seem to comprise areas that slip mostly during earthquakes, and areas that mostly slip aseismically. The size, location and frequency of earthquakes that a megathrust can generate thus depend on where and when aseismic creep is taking place, and what fraction of the long-term slip rate it accounts for. Here we address this issue by focusing on the central Peru megathrust. We show that the Pisco earthquake, with moment magnitude Mw = 8.0, ruptured two asperities within a patch that had remained locked in the interseismic period, and triggered aseismic frictional afterslip on two adjacent patches. The most prominent patch of afterslip coincides with the subducting Nazca ridge, an area also characterized by low interseismic coupling, which seems to have repeatedly acted as a barrier to seismic rupture propagation in the past. The seismogenic portion of the megathrust thus appears to be composed of interfingering rate-weakening and rate-strengthening patches. The rate-strengthening patches contribute to a high proportion of aseismic slip, and determine the extent and frequency of large interplate earthquakes. Aseismic slip accounts for as much as 50-70% of the slip budget on the seismogenic portion of the megathrust in central Peru, and the return period of earthquakes with M w = 8.0 in the Pisco area is estimated to be 250 years.