We have imaged the complex crustal and upper mantle structure beneath central Costa Rica using P-wave arrival times from locally recorded earthquakes. Thurber's (1983) iterative inversion method is used to simultaneously estimate velocities along a three-dimensional grid and hypocentral parameters of local earthquakes. Our data consist of over 12,000 arrival times from more than 1300 earthquakes recorded by stations of a permanent seismographic network in Costa Rica. Our resulting velocity model correlates well with mapped geologic units at very shallow depth and with tectonic features at greater depth. We find low velocities (4.0 to 4.8 km/sec) in the shallow crust (above 10 km) near the active volcanoes and associated with a NW-SE trending late Cretaceous to late Tertiary sedimentary basin southeast of Herradura peninsula. High velocities (5.4 to 5.7 km/sec) in the shallow crust correlate with outcrops of late Jurassic to early Tertiary ultramafic ophiolitic units and with basic Tertiary volcanic units. At depths between 20 and 30 km, high velocities (6.8 to 7.2 km/sec) are associated with the subducting Cocos plate under Costa Rica and two prominent low-velocity bodies (6.3 to 6.5 km/sec) are present about 30 km trenchward of the volcanic arc and along the projection of the aseismic Cocos Ridge as it subducts beneath Costa Rica. The thickened oceanic crust of the Cocos Ridge is most likely responsible for its low velocities. The deep low-velocity anomaly located trenchward of the axis of the volcanoes may indicate the presence of a low-density intrusive resulting from an earlier phase of magmatism, possibly the late Miocene episode that produced the Talamanca intrusive complex.