We report the coherent coupling of two electron spins at a distance via virtual microwave photons. Each spin is trapped in a silicon double quantum dot at either end of a superconducting resonator, achieving spin-photon couplings up to around gs/2p=40 MHz. As the two spins are brought into resonance with each other, but detuned from the photons, an avoided crossing larger than the spin linewidths is observed with an exchange splitting around 2J/2p=20 MHz. In addition, photon-number states are resolved from the shift 2?s/2p=-13 MHz that they induce on the spin frequency. These observations demonstrate that we reach the strong dispersive regime of circuit quantum electrodynamics with spins. Achieving spin-spin coupling without real photons is essential to long-range two-qubit gates between spin qubits and scalable networks of spin qubits on a chip.