A search for new physics is presented in final states with two oppositely charged leptons (electrons or muons), jets identified as originating from b quarks, and missing transverse momentum (pTmiss). The search uses proton-proton collision data at s=13 TeV amounting to 35.9 fb-1 of integrated luminosity collected using the CMS detector in 2016. Hypothetical signal events are efficiently separated from the dominant tt background with requirements on pTmiss and 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 top squarks. For top squarks, decaying exclusively to a top quark and a neutralino, exclusion limits are placed at 95% confidence level on the mass of the lightest top squark up to 800 GeV and on the lightest neutralino up to 360 GeV. These results, combined with searches in the single-lepton and all-jet final states, raise the exclusion limits up to 1050 GeV for the lightest top squark and up to 500 GeV for the lightest neutralino. For top squarks undergoing a cascade decay through charginos and sleptons, the mass limits reach up to 1300 GeV for top squarks and up to 800 GeV for the lightest neutralino. The results are also interpreted in a simplified model with a dark matter (DM) particle coupled to the top quark through a scalar or pseudoscalar mediator. For light DM, mediator masses up to 100 (50) GeV are excluded for scalar (pseudoscalar) mediators. The result for the scalar mediator achieves some of the most stringent limits to date in this model.