Taking the full complexity of subduction zones into account is important for realistic modeling and hazard assessment of subduction zone seismicity and associated tsunamis. Studying seismicity requires numerical methods that span a large range of spatial and temporal scales. We present the first coupled framework that resolves subduction dynamics over millions of years and earthquake dynamics down to fractions of a second. Using a two-dimensional geodynamic seismic cycle (SC) model, we model 4 million years of subduction followed by cycles of spontaneous megathrust events. At the initiation of one such SC event, we export the self-consistent fault and surface geometry, fault stress and strength, and heterogeneous material properties to a dynamic rupture (DR) model. Coupling leads to spontaneous dynamic rupture nucleation, propagation, and arrest with the same spatial characteristics as in the SC model. It also results in a similar material-dependent stress drop, although dynamic slip is significantly larger. The DR event shows a high degree of complexity, featuring various rupture styles and speeds, precursory phases, and fault reactivation. Compared to a coupled model with homogeneous material properties, accounting for realistic lithological contrasts doubles the amount of maximum slip, introduces local pulse-like rupture episodes, and relocates the peak slip from near the downdip limit of the seismogenic zone to the updip limit. When an SC splay fault is included in the DR model, the rupture prefers the splay over the shallow megathrust, although wave reflections do activate the megathrust afterward.