A search is presented for supersymmetric partners of the top quark (top squarks) in final states with two oppositely charged leptons (electrons or muons), jets identified as originating from b quarks, and missing transverse momentum. The search uses data from proton-proton collisions at s=13TeV collected with the CMS detector, corresponding to an integrated luminosity of 137fb-1. Hypothetical signal events are efficiently separated from the dominant top quark pair production background with requirements on the significance of the missing transverse momentum and on transverse mass variables. No significant deviation is observed from the expected background. Exclusion limits are set in the context of simplified supersymmetric models with pair-produced lightest top squarks. For top squarks decaying exclusively to a top quark and a lightest neutralino, lower limits are placed at 95 % confidence level on the masses of the top squark and the neutralino up to 925 and 450GeV, respectively. If the decay proceeds via an intermediate chargino, the corresponding lower limits on the mass of the lightest top squark are set up to 850GeV for neutralino masses below 420GeV. For top squarks undergoing a cascade decay through charginos and sleptons, the mass limits reach up to 1.4TeV and 900GeV respectively for the top squark and the lightest neutralino.