A search is performed for a long-lived particle decaying into a final state that includes a pair of muons of opposite-sign electric charge, using proton-proton collision data collected at s=13 TeV by the ATLAS detector at the Large Hadron Collider corresponding to an integrated luminosity of 32.9 fb-1. No significant excess over the Standard Model expectation is observed. Limits at 95% confidence level on the lifetime of the long-lived particle are presented in models of new phenomena including gauge-mediated supersymmetry or decay of the Higgs boson, H, to a pair of dark photons, ZD. Lifetimes in the range cτ=1–2400 cm are excluded, depending on the parameters of the model. In the supersymmetric model, the lightest neutralino is the next-to-lightest supersymmetric particle, with a relatively long lifetime due to its weak coupling to the gravitino, the lightest supersymmetric particle. The lifetime limits are determined for very light gravitino mass and various assumptions for the neutralino mass in the range 300–1000 GeV. In the dark photon model, the lifetime limits are interpreted as exclusion contours in the plane of the coupling between the ZD and the Standard Model Z boson versus the ZD mass (in the range 20–60 GeV), for various assumptions for the H→ZDZD branching fraction.