A search for the pair production of the lightest supersymmetric partner of the top quark (t~1) is presented. The search focuses on a compressed scenario where the mass difference between the top squark and the lightest supersymmetric particle, often considered to be the lightest neutralino (χ~01), is smaller than the mass of the W boson. The proton-proton collision data were recorded by the CMS experiment at a centre-of-mass energy of 13 TeV, and correspond to an integrated luminosity of 35.9 fb−1. In this search, two decay modes of the top squark are considered: a four-body decay into a bottom quark, two additional fermions, and a χ~01; and a decay via an intermediate chargino. Events are selected using the presence of a high-momentum jet, significant missing transverse momentum, and a low transverse momentum electron or muon. Two analysis techniques are used, targeting different decay modes of the t~1: a sequential selection and a multivariate technique. No evidence for the production of top squarks is found, and mass limits at 95% confidence level are set that reach up to 560 GeV, depending on the m(t~1)−m(χ~01) mass difference a ... mehrnd the decay mode.