Near-field ground motion is the major blind spot of seismic hazard studies, mainly because of the challenges in accounting for source effects. Initial stress heterogeneity is an important component of physics-based approaches to ground motion prediction that represent source effects through dynamic earthquake rupture modeling. We hypothesize that stress heterogeneity on a fault primarily originates from past background seismicity. We develop a new method to generate stochastic stress distributions as a superposition of residual stresses left by previous ruptures that are consistent with regional distributions of earthquake size and hypocentral depth. We validate our method on Mw 7 earthquake models suitable for California, by obtaining a satisfactory agreement with empirical earthquake scaling laws and ground motion prediction equations. To avoid the excessive seismic radiation produced by dynamic models with abrupt arrest at preset rupture borders, we achieve spontaneous rupture arrest by incorporating a scale-dependent fracture energy adjusted with fracture mechanics theory. Our analyses of rupture and ground motion reveal particular signatures of the initial stress heterogeneity: rupture can locally propagate at supershear speed near the highly-stressed areas; the position of high-stress and low-stress areas due to initial stress heterogeneity determines how the peak ground motion amplitudes and polarization spatially vary along the fault, as low-stress areas slows down the rupture, decrease stress drop, and change the radiation distribution before the rupture arrest. We also find that the medium stratification amplifies the moment rate spectrum at frequencies above 2 Hz, which requires understanding the interaction between site effects and rupture dynamics; therefore, we highlight the need to consider a realistic fault medium on future studies of rupture dynamics. Our approach advances our understanding of the relations between dynamic features of earthquake ruptures and the statistics of regional seismicity, and our capability to model source effects for near-field ground motion prediction studies.