A search for pair production of supersymmetric particles in events with two oppositely charged leptons (electrons or muons) and missing transverse momentum is reported. The data sample corresponds to an integrated luminosity of 35.9 fb−1 of proton-proton collisions at s=13 TeV collected with the CMS detector during the 2016 data taking period at the LHC. No significant deviation is observed from the predicted standard model background. The results are interpreted in terms of several simplified models for chargino and top squark pair production, assuming R-parity conservation and with the neutralino as the lightest supersymmetric particle. When the chargino is assumed to undergo a cascade decay through sleptons, with a slepton mass equal to the average of the chargino and neutralino masses, exclusion limits at 95% confidence level are set on the masses of the chargino and neutralino up to 800 and 320 GeV, respectively. For top squark pair production, the search focuses on models with a small mass difference between the top squark and the lightest neutralino. When the top squark decays into an off-shell top quark and a neutralino, the limits extend up to 420 and 360 GeV for the top squark and neutralino masses, respectively.[Figure not available: see fulltext.].