We present the quasi-stellar object (QSO) luminosity function (LF) of the completed 2dF–SDSS LRG and QSO (2SLAQ) survey, based on QSOs photometrically selected from Sloan Digital Sky Survey (SDSS) imaging data and then observed spectroscopically using the 2dF instrument on the Anglo-Australian Telescope. We analyse 10 637 QSOs in the redshift range 0.4 < z < 2.6 to a g-band flux limit of 21.85 (extinction-corrected) and an absolute continuum magnitude of Mg(z= 2) < −21.5. This sample covers an area of 191.9 deg2. The binned QSO LF agrees with that of the brighter SDSS main QSO sample, but extends ∼2.5 mag fainter, clearly showing the flattening of the LF towards faint absolute magnitudes. 2SLAQ finds an excess of QSOs compared to the 2dF QSO Redshift Survey at g > 20.0, as found previously by Richards et al. The LF is consistent with other previous, much smaller, samples produced to the depth of 2SLAQ. By combining the 2SLAQ and SDSS QSO samples, we produce a QSO LF with an unprecedented combination of precision and dynamic range. With this we are able to accurately constrain both the bright and faint ends of the QSO LF. While the overall trends seen in the evolution of the QSO LF appear similar to pure luminosity evolution, the data show very significant departures from such a model. Most notably we see clear evidence that the number density of faint QSOs peaks at lower redshift than bright QSOs: QSOs with Mg > −23 have space densities which peak at z < 1, while QSOs at Mg < −26 peak at z > 2. By fitting simple LF models in narrow Mg intervals, we find that this downsizing is significant at the 99.98 per cent level. We show that LF models which follow the pure luminosity evolution form [i.e. M*g≡M*g(z)], but with a redshift-dependent bright-end slope and an additional density evolution term, Φ*≡Φ*(z), provide a much improved fit to the data. The bright-end slope, , steepens from ≃−3.0 at z≃ 0.5 to =−3.5 at z≃ 2.5. This steepening is significant at the 99.9 per cent level. We find a decline in Φ* from z≃ 0.5 to 2.5 which is significant at the 94 per cent level.