A two-step nonlinear and linear inversion is carried out to map the lateral heterogeneity beneath North America using surface wave data. The lateral resolution for most areas of the model is of the order of several hundred kilometers. The most obvious feature in the tomographic images is the rapid transition between low velocities in the technically active region west of the Rocky Mountains and high velocities in the stable central and eastern shield of North America. The model also reveals smaller-scale heterogeneous velocity structures. A high-velocity anomaly is imaged beneath the state of Washington that could be explained as the subducting Juan de Fuca plate beneath the Cascades. A large low-velocity structure extends along the coast from the Mendocino to the Rivera triple junction and to the continental interior across the southwestern United States and northwestern Mexico. Its shape changes notably with depth. This anomaly largely coincides with the part of the margin where no lithosphere is consumed since the subduction has been replaced by a transform fault. Evidence for a discontinuous subduction of the Cocos plate along the Middle American Trench is found. In central Mexico a transition is visible from low velocities across the Trans-Mexican Volcanic Belt (TMVB) to high velocities beneath the Yucatan Peninsula. Two elongated low-velocity anomalies beneath the Yellowstone Plateau and the eastern Snake River Plain volcanic system and beneath central Mexico and the TMVB seem to be associated with magmatism and partial melting. Another low-velocity feature is seen at depths of approximately 200 km beneath Florida and the Atlantic Coastal Plain. The inversion technique used is based on a linear surface wave scattering theory, which gives tomographic images of the relative phase velocity perturbations in four period bands ranging from 40 to 150 s. In order to find a smooth reference model a nonlinear inversion based on ray theory is first performed. After correcting for the crustal thickness the phase velocity perturbations obtained from the subsequent linear waveform inversion for the different period bands are converted to a three-layer model of S velocity perturbations (layer 1, 25-100 km; layer 2, 100-200 km) layer 3, 200-300 km). We have applied this method on 275 high-quality Rayleigh waves recorded by a variety of instruments in North America (IRIS/USGS, IRIS/IDA, TERRAscope, RSTN). Sensitivity tests indicate that the lateral resolution is especially good in the densely sampled western continental United States, Mexico, and the Gulf of Mexico.