On 6 September 2002 a M w 5.9 earthquake occurred in the southern Tyrrhenian sea, 40 km off the coast of Palermo (Italy). In the days after the mainshock, eight temporary stations were installed in the city to record aftershocks on different geological formations. Seismograms of about 30 earthquakes with magnitude Ն2.8 are analyzed. The data analysis confirms the role of near-surface geology in causing locally significant variations of the ground-shaking level as already inferred by Guidoboni et al. (2003) from historical damage scenario studies. The largest spectral variations estimated through aftershock recordings result in a factor of 10 difference between stiff and soft sites, in frequency bands varying from 1 to 3.5 Hz. The geological structure of the study area is reconstructed by using data from more than 2000 boreholes organized in a Geographic Information System specifically dedicated to the assessment of natural hazards in urban areas. Vertically varying velocity models are used for a comparison with the observed data. In general, 1D transfer functions fit the largest amplification frequency but underestimate amplitudes of observations probably because of 2D and 3D complexity. Because the seismic stations were not installed in free field but at ground or underground level inside buildings, a possible influence of the structure was also investigated. Simultaneous ambient noise measurements were performed on the top, at the base, and outside the buildings where stations were installed. For all but one site, this analysis shows that the estimated ground-motion amplifications do not reflect the building vibration modes and therefore, in these cases, soil-structure interaction does not bias the free-field response of the study sites. Finally, speculations on the effect of the local geology in terms of response spectra of the M w 5.9 mainshock are discussed in the framework of the Eurocode 8 prescriptions.