Aims. This paper describes the Polarimetric and Helioseismic Imager on the Solar Orbiter mission (SO/PHI), the first magnetograph and helioseismology instrument to observe the Sun from outside the Sun-Earth line. It is the key instrument meant to address the top-level science question: How does the solar dynamo work and drive connections between the Sun and the heliosphere? SO/PHI will also play an important role in answering the other top-level science questions of Solar Orbiter, as well as hosting the potential of a rich return in further science. Methods. SO/PHI measures the Zeeman effect and the Doppler shift in the Fe i 617.3 nm spectral line. To this end, the instrument carries out narrow-band imaging spectro-polarimetry using a tunable LiNbO 3 Fabry-Perot etalon, while the polarisation modulation is done with liquid crystal variable retarders (LCVRs). The line and the nearby continuum are sampled at six wavelength points and the data are recorded by a 2k × 2k CMOS detector. To save valuable telemetry, the raw data are reduced on board, including being inverted under the assumption of a Milne-Eddington atmosphere, although simpler reduction methods are also available on board. SO/PHI is composed of two telescopes; one, the Full Disc Telescope (FDT), covers the full solar disc at all phases of the orbit, while the other, the High Resolution Telescope (HRT), can resolve structures as small as 200 km on the Sun at closest perihelion. The high heat load generated through proximity to the Sun is greatly reduced by the multilayer-coated entrance windows to the two telescopes that allow less than 4% of the total sunlight to enter the instrument, most of it in a narrow wavelength band around the chosen spectral line. Results. SO/PHI was designed and built by a consortium having partners in Germany, Spain, and France. The flight model was delivered to Airbus Defence and Space, Stevenage, and successfully integrated into the Solar Orbiter spacecraft. A number of innovations were introduced compared with earlier space-based spectropolarimeters, thus allowing SO/PHI to fit into the tight mass, volume, power and telemetry budgets provided by the Solar Orbiter spacecraft and to meet the (e.g. thermal) challenges posed by the mission's highly elliptical orbit.