Several models of physics beyond the Standard Model predict the existence of dark photons, light neutral particles decaying into collimated leptons or light hadrons. This paper presents a search for long-lived dark photons produced from the decay of a Higgs boson or a heavy scalar boson and decaying into displaced collimated Standard Model fermions. The search uses data corresponding to an integrated luminosity of 36.1 fb- 1 collected in proton–proton collisions at s=13 Te recorded in 2015–2016 with the ATLAS detector at the Large Hadron Collider. The observed number of events is consistent with the expected background, and limits on the production cross section times branching fraction as a function of the proper decay length of the dark photon are reported. A cross section times branching fraction above 4 pb is excluded for a Higgs boson decaying into two dark photons for dark-photon decay lengths between 1.5 mm and 307 mm.