Context: The unprecedented astrometric precision of the Gaia mission relies on accurate estimates of the locations of sources in the Gaia data stream. This is ultimately performed by point spread function (PSF) fitting, which in turn requires an accurate reconstruction of the PSF. Gaia Early Data Release 3 (EDR3) will, for the first time, use a PSF calibration that models several of the strongest dependences, leading to signficantly reduced systematic errors. Aims: We describe the PSF model and calibration pipeline implemented for Gaia EDR3, including an analysis of the calibration results over the 34 months of data. We include a discussion of the limitations of the current pipeline and directions for future releases. This will be of use both to users of Gaia data and as a reference for other precision astrometry missions. Methods: We develop models of the 1D line spread function (LSF) and 2D PSF profiles based on a linear combination of basis components. We fit the models to selected primary sources in independent time ranges, using simple parameterisations for the colour and other dependences. Variation in time is smoothed by merging the independent calibrations in a square root information filter, with resets at certain mission events that induce a discontinuous change in the PSF. Results: The PSF calibration shows strong time and colour dependences that accurately reproduce the varying state of the Gaia astrometric instrument. Analysis of the residuals reveals both the performance and the limitations of the current models and calibration pipeline, and indicates the directions for future development. Conclusions: The PSF modelling and calibration carried out for Gaia EDR3 represents a major step forwards in the data processing and will lead to reduced systematic errors in the core mission data products. Further significant improvements are expected in the future data releases.