We investigate the stellar population and star formation history of the Upper Scorpius OB association, the most nearby region of recent massive star formation, over the full stellar mass range from 0.1 to 20 Msolar. The first part of this paper describes an extension of our large spectroscopic survey (Preibisch et al., published in 2001) for low-mass pre-main-sequence (PMS) stars in Upper Scorpius. Using the multiobject spectrograph 2dF at the Anglo-Australian Telescope, we obtained spectra of 469 stars with magnitudes R=12.5-18.0 in a 6 deg2 area. Among these, we find 68 new PMS stars, nearly all of them M-type stars, by their strong lithium absorption lines. The total area covered by our 2dF survey is now 9 deg2 and contains 166 new PMS stars. Combining these results with our earlier investigation (Preibisch & Zinnecker) yields a sample of 250 PMS stars in the mass range ~0.1 to ~2 Msolar. The location of these stars in the HR diagram suggests a mean age of 5 Myr without a significant age spread. In the second part of this paper, we also consider the population of 114 high-mass members identified in detailed Hipparcos studies. We construct a combined HR diagram for the 364 high- and low-mass members and find that the whole stellar population is very well characterized by a very narrow age distribution around 5 Myr. We estimate individual masses for all members and construct an empirical mass function covering the mass range from 0.1 up to 20 Msolar. A power-law fit to the mass function gives a slope of α~-2.6 above ~2 Msolar and a much flatter slope (α~-0.9) below ~0.6 Msolar. The initial mass function of Upper Sco is not identical, but within the errors consistent with recent determinations of the field initial mass function. There is certainly no deficit of low-mass stars in the Upper Sco OB association, but rather a small excess of low-mass stars. Our results on the stellar age distribution confirm earlier indications that the star formation process in Upper Sco was triggered and support previous conjectures that the triggering event was a supernova shock wave originating from the nearby Upper Centaurus-Lupus association.