In many quantum architectures the solid-state qubits, such as quantum dots or color centers, are interfaced via emitted photons. However, the frequency of photons emitted by solid-state systems exhibits slow uncontrollable fluctuations over time (spectral diffusion), creating a serious problem for implementation of the photon-mediated protocols. Here we show that a sequence of optical pulses applied to the solid-state emitter can stabilize the emission line at the desired frequency. We demonstrate efficiency, robustness, and feasibility of the method analytically and numerically. Taking nitrogen-vacancy (NV) center in diamond as an example, we show that only several pulses, with the width of 1 ns, separated by few ns (which is not difficult to achieve) can suppress spectral diffusion. Our method provides a simple and robust way to greatly improve the efficiency of photonmediated entanglement and/or coupling to photonic cavities for solid-state qubits.The ability to transfer quantum information between the stationary qubits via photons is at the heart of many applications such as long-range quantum networks and quantum interface between distant qubits [1][2][3][4][5][6]. The photon-mediated entanglement is based on indistinguishable photons (having the same polarization and frequency) emitted by two different stationary qubits and entangled with them [3][4][5] 7]. It is of central importance for such solid-state qubits as quantum dots and color centers, which are often difficult to couple directly, while the photon-mediated protocols present a very promising alternative [4][5][6]. At low temperatures, a noticeable fraction of photons emitted from these qubits is concentrated in the zero-phonon line (ZPL) and is insensitive to the phonon absorption/emission. The photons emitted into the ZPL are naturally entangled to the originating solid-state qubits [6,[8][9][10][11][12][13], and constitute excellent flying qubits; the emission into the ZPL can be enhanced by placing the qubit into a cavity [14,15].However, ensuring indistinguishability of the photons emitted by two different quantum dots or color centers remains a crucial challenge [4, 5,[16][17][18][19][21][22][23]. Changes in the local strain and motion of the charges around the emitter lead to slow random variation (spectral diffusion) of the energies of the levels involved in the photon emission. The position of the ZPL (i.e. the frequency of the emitted photons) fluctuates with the amplitude far exceeding the natural linewidth. Thus, the spectral overlap between the photons coming from two different qubits is greatly reduced, resulting in low efficiency of the heralded entanglement process. The same problem occurs when the qubit is coupled to the photonic cavity: due to spectral diffusion of the ZPL, the overlap of the emitted photons with the cavity line is diminished, thereby reducing the Purcell enhancement. Due to severity of the problem, solutions have been actively sought, and the schemes based e.g. on active feedback [17][18][19][20], three-level em...