A search for exclusive two-photon production via photon exchange in proton-proton collisions, pp → pγγp with intact protons, is presented. The data correspond to an integrated luminosity of 9.4 fb−1 collected in 2016 using the CMS and TOTEM detectors at a center-of-mass energy of 13 TeVat the LHC. Events are selected with a diphoton invariant mass above 350 GeVand with both protons intact in the final state, to reduce backgrounds from strong interactions. The events of interest are those where the invariant mass and rapidity calculated from the momentum losses of the forward-moving protons match the mass and rapidity of the central, two-photon system. No events are found that satisfy this condition. Interpreting this result in an effective dimension-8 extension of the standard model, the first limits are set on the two anomalous four-photon coupling parameters. If the other parameter is constrained to its standard model value, the limits at 95% confidence level are |ζ1| \u3c 2.9 × 10−13 GeV−4 and |ζ2| \u3c 6.0 × 10−13 GeV−4