A new search for the electroweak production of supersymmetric particles decaying into two leptons with missing transverse momentum is presented. Assuming R-parity conservation, two simplified models are considered: direct pair production of sleptons decaying into the lightest neutralinos through leptons of the Standard Model (SM) and direct pair production of the lightest charginos decaying into the lightest neutralinos through W bosons of the SM. The analysis targets phase space regions where the difference in mass between the slepton or the lightest chargino and the lightest neutralino is close to or below the mass of the W boson. Such regions with compressed mass spectra have not been covered by any searches conducted so far due to the low cross section of the supersymmetric signal. Therefore, improved analysis strategies are crucial to separate the supersymmetric signal from the SM backgrounds. A search for an excess of same-flavour lepton pairs in opposite-sign lepton events is made in the direct slepton pair production analysis while a multivariate approach using gradient boosted decision trees is exploited in the chargino pair production analysis and considering both the same-flavour and different-flavour channels. No significant excesses over the expected background are observed using proton-proton collisions data collected by the ATLAS experiment at 13 TeV and exclusion limits at 95% confidence level are set for each considered model. Exclusion limits are also set for selectrons and smuons separately and portions of the region excluded by the search of smuons pair production are expected to be compatible with the muon g-2 anomaly for small tan(beta) values.