The problems of neutrino masses, matter-antimatter asymmetry, and dark matter could be successfully addressed by postulating right-handed neutrinos with Majorana masses below the electroweak scale. In this work, leptonic decays of W bosons extracted from 32.9 fb−1 to 36.1 fb−1 of 13 TeV proton–proton collisions at the LHC are used to search for heavy neutral leptons (HNLs) that are produced through mixing with muon or electron neutrinos. The search is conducted using the ATLAS detector in both prompt and displaced leptonic decay signatures. The prompt signature requires three leptons produced at the interaction point (either μμe or eeμ) with a veto on same-flavour opposite-charge topologies. The displaced signature comprises a prompt muon from the W boson decay and the requirement of a dilepton vertex (either μμ or μe) displaced in the transverse plane by 4–300 mm from the interaction point. The search sets constraints on the HNL mixing to muon and electron neutrinos for HNL masses in the range 4.5–50 GeV. [Figure not available: see fulltext.]