The FASER experiment at the LHC is designed to search for light, weakly-interacting particles produced in proton-proton collisions at the ATLAS interaction point that travel in the far-forward direction. The first results from a search for dark photons decaying to an electron-positron pair, using a dataset corresponding to an integrated luminosity of 27.0 fb−1 collected at centre-of-mass energy s=13.6 TeV in 2022 in LHC Run 3, are presented. No events are seen in an almost background-free analysis, yielding world-leading constraints on dark photons with couplings ϵ∼2×10−5−1×10−4 and masses ∼17 MeV−70 MeV. The analysis is also used to probe the parameter space of a massive gauge boson from a U(1)B−L model, with couplings gB−L∼5×10−6−2×10−5 and masses ∼15 MeV−40 MeV excluded for the first time.