A search for direct production of top squark pairs in events with jets and large transverse momentum imbalance is presented. The data are based on proton-proton collisions at a center-of-mass energy of 13 TeV, collected with the CMS detector in 2016 at the CERN LHC, and correspond to an integrated luminosity of 35.9 fb−1. The search considers a variety of R-parity conserving supersymmetric models, including ones for which the top squark and neutralino masses are nearly degenerate. Specialized jet reconstruction tools are developed to exploit the unique characteristics of the signal topologies. With no significant excess of events observed above the standard model expectations, upper limits are set on the direct top squark pair production cross section in the context of simplified supersymmetric models for various decay hypotheses. Models with larger differences in mass between the top squark and neutralino are probed for masses up to 1040 and 500 GeV, respectively, whereas models with a more compressed mass hierarchy are probed up to 660 and 610 GeV, respectively. The smallest mass difference probed is for masses near to 550 and 540 ... mehr GeV, respectively.