A search for a Higgs boson decaying into a pair of electrons or muons and a photon is described. Higgs boson decays to a Z boson and a photon (H Z , = e or ), or to two photons, one of which has an internal conversion into a muon pair (H (*) ) were considered. The analysis is performed using a data set recorded by the CMS experiment at the LHC from proton-proton collisions at a center-of-mass energy of 13 TeV, corresponding to an integrated luminosity of 35.9 fb(-1). No significant excess above the background prediction has been found. Limits are set on the cross section for a standard model Higgs boson decaying to opposite-sign electron or muon pairs and a photon. The observed limits on cross section times the corresponding branching fractions vary between 1.4 and 4.0 (6.1 and 11.4) times the standard model cross section for H (*) (H Z ) in the 120-130 GeV mass range of the system. The H (*) and H Z analyses are combined for m(H) =125GeV, obtaining an observed (expected) 95% confidence level upper limit of 3.9 (2.0) times the standard model cross section.