A major challenge in using spins in the solid state for quantum technologies is protecting them from sources of decoherence. This is particularly important in nanodevices where the proximity of material interfaces, and their associated defects, can play a limiting role. Spin decoherence can be addressed to varying degrees by improving material purity or isotopic composition, for example, or active error correction methods such as dynamic decoupling (or even combinations of the two). However, a powerful method applied to trapped ions in the context of atomic clocks is the use of particular spin transitions that are inherently robust to external perturbations. Here, we show that such 'clock transitions' can be observed for electron spins in the solid state, in particular using bismuth donors in silicon. This leads to dramatic enhancements in the electron spin coherence time, exceeding seconds. We find that electron spin qubits based on clock transitions become less sensitive to the local magnetic environment, including the presence of (29)Si nuclear spins as found in natural silicon. We expect the use of such clock transitions will be of additional significance for donor spins in nanodevices, mitigating the effects of magnetic or electric field noise arising from nearby interfaces and gates.