A search for exclusive two-photon production via photon exchange in proton-proton collisions, pp $\to$ p$\gamma\gamma$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 TeV at the LHC. Events are selected with a diphoton invariant mass above 350 GeV and 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 matches 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% CL are $\lvert\zeta_1\rvert$ $\lt$ 2.9 $\times$ 10$^{-13}$ GeV$^{-4}$ and $\lvert\zeta_2\rvert$ $\lt$ 6.0 $\times$ 10$^{-13}$ GeV$^{-4}$.