Spin resonance of individual spin centers allows applications ranging from quantum information technology to atomic-scale magnetometry. To protect the quantum properties of a spin, control over its local environment, including energy relaxation and decoherence processes, is crucial. However, in most existing architectures, the environment remains fixed by the crystal structure and electrical contacts. Recently, spin-polarized scanning tunneling microscopy (STM), in combination with electron spin resonance (ESR), allowed the study of single adatoms and inter-atomic coupling with an unprecedented combination of spatial and energy resolution. We elucidate and control the interplay of an Fe single spin with its atomic-scale environment by precisely tuning the phase coherence time T2 using the STM tip as a variable electrode. We find that the decoherence rate is the sum of two main contributions. The first scales linearly with tunnel current and shows that, on average, every tunneling electron causes one dephasing event. The second, effective even without current, arises from thermally activated spin-flip processes of tip spins. Understanding these interactions allows us to maximize T2 and improve the energy resolution. It also allows us to maximize the amplitude of the ESR signal, which supports measurements even at elevated temperatures as high as 4 K. Thus, ESR-STM allows control of quantum coherence in individual, electrically accessible spins.