We present measurements of the cosmic microwave background (CMB) lensing
potential using the final $\textit{Planck}$ 2018 temperature and polarization
data. We increase the significance of the detection of lensing in the
polarization maps from $5\,\sigma$ to $9\,\sigma$. Combined with temperature,
lensing is detected at $40\,\sigma$. We present an extensive set of tests of
the robustness of the lensing-potential power spectrum, and construct a
minimum-variance estimator likelihood over lensing multipoles $8 \le L \le
400$. We find good consistency between lensing constraints and the results from
the $\textit{Planck}$ CMB power spectra within the $\rm{\Lambda CDM}$ model.
Combined with baryon density and other weak priors, the lensing analysis alone
constrains $\sigma_8 \Omega_{\rm m}^{0.25}=0.589\pm 0.020$ ($1\,\sigma$
errors). Also combining with baryon acoustic oscillation (BAO) data, we find
tight individual parameter constraints, $\sigma_8=0.811\pm0.019$,
$H_0=67.9_{-1.3}^{+1.2}\,\text{km}\,\text{s}^{-1}\,\rm{Mpc}^{-1}$, and
$\Omega_{\rm m}=0.303^{+0.016}_{-0.018}$. Combining with $\textit{Planck}$ CMB
power spectrum data, we measure $\sigma_8$ to better than $1\,\%$ precision,
finding $\sigma_8=0.811\pm 0.006$. We find consistency with the lensing results
from the Dark Energy Survey, and give combined lensing-only parameter
constraints that are tighter than joint results using galaxy clustering. Using
$\textit{Planck}$ cosmic infrared background (CIB) maps we make a combined
estimate of the lensing potential over $60\,\%$ of the sky with considerably
more small-scale signal. We demonstrate delensing of the $\textit{Planck}$
power spectra, detecting a maximum removal of $40\,\%$ of the lensing-induced
power in all spectra. The improvement in the sharpening of the acoustic peaks
by including both CIB and the quadratic lensing reconstruction is detected at
high significance (abridged).