A search for heavy right-handed Majorana or Dirac neutrinos NR and heavy right-handed gauge bosons WR is performed in events with a pair of energetic electrons or muons, with the same or opposite electric charge, and two energetic jets. The events are selected from pp collision data with an integrated luminosity of 36.1 fb−1 collected by the ATLAS detector at s=13 TeV. No significant deviations from the Standard Model are observed. The results are interpreted within the theoretical framework of a left-right symmetric model and lower limits are set on masses in the heavy right-handed W boson and neutrino mass plane. The excluded region extends to mRR=4.7 TeV for both Majorana and Dirac NR neutrinos.