## Introduction

Single lanthanide atoms adsorbed on surfaces or incorporated in molecular complexes are being pursued in recent years for applications in quantum information technology and high-density magnetic data storage. Major advances in these domains include all-electrical read-out1 and coherent control of their nuclear spins2, the use of atomic clock transitions to protect their spins against dipolar decoherence3, the discovery of single atom magnets4,5, and the ability to manipulate their spin states6. Recently, a distinct class of molecular magnets containing a single Dy atom has even pushed the limit of operational temperatures up to 80 K by enhancing the MAE7,8. Higher uniaxial MAE acts as a barrier against spontaneous reversal of magnetic spins9,10,11, thus enhancing their magnetic lifetimes. The charge balance in such molecular magnets, however, necessitates the use of anionic counterparts, posing limitations on isolating and supporting them on a solid-state substrate. In contrast, single lanthanide atoms can be directly adsorbed on insulating MgO substrates, and due to the linear bond formed at the oxygen site, large MAE values are also expected12. Among the late lanthanides, terbium (Tb), Dy, and holmium (Ho) atoms exhibit large MAE in a uniaxial crystal field (CF)12,13, which led to the first few lanthanide-based single-chain magnets with slow magnetic relaxation14,15. In particular, Dy ions and diatomic units deposited on MgO are predicted to possess significantly larger MAE compared to their counterparts containing Ho12. Additionally, the seminal single-atom magnet, Ho on MgO4, despite its long magnetic lifetime, lacks resilience against slow sweep rates of tip-magnetic fields16.

In this work, we report the first single-atom magnet on a surface that maintains stability at zero external magnetic field as well as against slow magnetic field sweeps, and hence can be used to create atomically localized magnetic fields. We observe magnetic stability of several days in Dy atoms adsorbed on MgO at ≈1 K with a giant MAE of 250 meV, using a low-temperature STM combined with single-atom ESR capability17. Using a spin-polarized tip (SP-tip) we measure random telegraph signal of the two magnetic states in Dy atom and reveal that the magnetization reversal becomes possible only via scattering with tunnelling electrons of energies higher than 140 meV, which is twice compared to the case of single Ho atoms adsorbed on MgO/Ag(100)18. By employing tip-field sweeps19 on sensor Fe atoms20, we directly measure the magnetic dipolar fields from Dy (BDy), which show absence of all major relaxation pathways at low and even zero external magnetic field (Bext)21, unlike Dy-based single-molecule magnets7,22,23. We harness this zero-field magnetic stability in single Dy atoms in several engineered Fe–Dy structures, to demonstrate atomically precise control of magnetic fields.

## Results

Figure 1 a shows a constant current STM image highlighting both Fe and Dy single atoms adsorbed atop an oxygen-site of a bilayer MgO patch grown on Ag(001) (see “Methods”). For characterizing the magnetic stability of the Dy atom, we first investigate it with an SP-tip prepared by transferring several Fe atoms from the MgO surface to the tip-apex24. SP-tips offer spin-sensitive read-out via tunnelling magnetoresistance. Thus, a magnetic contrast between two distinct Dy-spin orientations is recorded as switching events in the time-trace of the tip–sample distance (Δz) for fixed tunnelling currents (Fig. 1b)6,25,26. The switching rate increases with bias voltage Vdc, while no magnetization reversal is ever observed for Vdc < 140 meV. From the bias-voltage-dependent switching events measured at 5 T out-of-plane magnetic field (Fig. 1c), we identify two dominant thresholds, at 155 mV and 235 mV (Table S2), which are twice compared to the respective values reported for single Ho atoms on MgO/Ag(001)18. In order to identify the magnetization reversal mechanisms associated with these thresholds, we perform point-charge-based multiplet simulations27. Figure 1d illustrates the resulting energy level distribution of a single Dy atom in 4f9 configuration, indicating an out-of-plane total MAE of 250–meV with a ground state Kramer doublet of $$\langle {J}_{z}\rangle =\pm\!\frac{15}{2}$$ and a magnetic moment of 9.9μB. Note that the 4f10 configuration results in significantly reduced MAE (Fig. S8). Due to the fourfold symmetry of the O-adsorption site, the eigenstates of the system are linear combinations of several Jz states28 separated by ΔmJ = ± 4. The resulting state mixing is stronger for states with lower 〈Jz〉 (Fig. 1d). In presence of the tunnelling electrons, this opens up transitions between an initial and a final state with probabilities defined by the interaction operator $${\boldsymbol{J}}\cdot {\boldsymbol{\sigma }}={J}_{z}{\sigma }_{z}+\frac{1}{2}({J}_{+}{\sigma }_{-}+{J}_{-}{\sigma }_{+})$$, where J+,− are the ladder operators of the Dy angular momentum J, and σ is the spin operator of the tunnelling electrons29. The selection rule for Jσ allows transitions for ΔJz = 0, ± 1(mod4), where ΔJz is the difference between initial and final state values of 〈Jz〉. Consequently, we identify seven major routes of different intensities within 146–248 meV, which enable spin–flip events (Fig. 1d). The corresponding calculated switching probabilities for different Δm transitions are in good agreement with experimentally measured thresholds shown in Fig. 1c (see Supplementary section 8).

Although the giant MAE of 250 meV largely reduces the probability of spin-transitions over the anisotropy barrier, it does not ensure magnetic stability against quantum tunnelling. However, following Kramer’s theorem30, the ground state of Dy with half-integer value of 〈Jz〉 should remain doubly-degenerate at Bext = 0 T, thereby implying a vanishing transition probability between $$\langle {J}_{z}\rangle =\pm \frac{15}{2}$$. In order to verify this zero-field magnetic stability of Dy, we employ a specific ESR detection method operating in zero external magnetic field and using sweeps of the tip magnetic field only (Btip)19. We probe the stability of the Dy spin states via coupled sensor Fe atoms in engineered Fe–Dy pairs of varying interatomic distances d (see Supplementary section 6). As illustrated in Fig. 2a, the radio frequency (RF) is kept constant (f0) and tip-field sweeps are achieved by varying the tunnelling current at constant Vdc, thereby changing tip–sample distance (see “Methods” and Supplementary section 2). For the following, it is important to note that the SP-tips used in this work for measuring tip-field sweep ESR showed magnetic bistability in low fields (Bext < 60 mT), with lifetimes typically shorter than the timescales of our measurements (see Supplementary section 2). This results in two different orientations of the tip-fields with respect to all static magnetic fields (Bstatic). Thus, considering only the out-of-plane projections from both Btip and Bstatic = BDy + Bext, the generic condition for driving tip-field sweep ESR in Fe atoms in strong tip-field regimes (Btip > Bstatic) can be written as (see “Methods”):

$$\frac{h{f}_{0}}{2{\mu }_{{\rm{Fe}}}}=| \pm {B}_{{\rm{tip}}}+{B}_{{\rm{static}}}| =| {B}_{{\rm{tip}}}| \pm | {B}_{{\rm{Dy}}}+{B}_{{\rm{ext}}}|$$
(1)

Here, h is Planck’s constant and μFe is the magnetic moment of the sensor Fe atom. In the absence of any static magnetic field (BDy = 0 and Bext = 0), spin resonance occurs when the tip-field induced Zeeman splitting between the two lowest lying states of the Fe atom (2μFeBtip)17 matches B0 = hf0, leading to a single resonance (Fig. 2b). However, in the presence of a static dipolar field from Dy, (BDy ≠ 0 and Bext = 0), the resonance results from two different relative alignments of Btip and BDy. Consequently, the resonance condition is satisfied at two distinct tip-fields centred around $$\frac{h{f}_{0}}{2{\mu }_{{\rm{Fe}}}}$$, i.e., $${B}_{{\rm{tip}}}^{1}=\frac{h{f}_{0}}{2{\mu }_{{\rm{Fe}}}}-{B}_{{\rm{Dy}}}$$ and $${B}_{{\rm{tip}}}^{2}=\frac{h{f}_{0}}{2{\mu }_{{\rm{Fe}}}}+{B}_{{\rm{Dy}}}$$. This interpretation is in excellent agreement with our observation of two ESR peaks for the Fe atom in a Fe–Dy pair at Bext = 0 T (Fig. 2b). Note that the separation between the two resonance peaks in Fe–Dy pairs directly provides a measure of the out-of-plane magnetic field generated by a single Dy atom (BDy). Within magnetic dipole approximations this is proportional to the out-of-plane magnetic moment of the Dy atom (μDy) as $${B}_{{\rm{Dy}}}=\frac{{\mu }_{0}{\mu }_{{\rm{Dy}}}}{4\pi }\times {d}^{-3}$$, where μ0 is the vacuum permeability.

The two-resonance feature also appears at small non-zero values of Bext for isolated Fe atoms as shown in Fig. 3a (left panel). This illustrates that the effect of the Dy dipolar field on a neighbouring Fe atom (Fig. 2b, top) is the same as having a static external magnetic field only. The positions of the two ESR peaks evolve linearly with Bext for all cases (Fig. 3a). However, for the Fe–Dy pairs the two ESR peaks merge when the external magnetic field compensates the dipolar field from the Dy atom (Bext = −BDy), thereby shifting them with respect to the isolated Fe case (Fig. 3b). From these measurements we infer the dipolar field of the Dy atom for several Fe–Dy pairs of varying interatomic distance (Fig. 3c). Note that we observe an excellent agreement between frequency sweep and tip-field sweep ESR at two different set frequencies which suggests that tip-fields are not influenced by the presence of the Dy atom (see Supplementary section 2). We fit the BDy values obtained from all ESR measurements to the explicit distance dependence $${B}_{{\rm{Dy}}}=\frac{{\mu }_{0}{\mu }_{{\rm{Dy}}}}{4\pi }\times {d}^{-3}$$ and obtain μDy = 10.1 ± 0.3μB, in agreement with the multiplet analysis and the atomic value for Dy in gas phase.

Note that we never observe any spin-switching in Dy over days against repeated cycles of Bext ramps within ± 30 mT (see Supplementary section 3), despite an isotopic composition which bears the possibility of spin–flip transitions at low magnetic fields via hyperfine interaction in 161Dy (19% natural abundance) and 163Dy (25% natural abundance). This is in contrast to the case of single Ho atoms on MgO, where spin-switching was observed at slow magnetic field sweeps16. Moreover, the magnetic state of the Dy atom is also stable against high magnetic fields of 5 T and heating of at least up to 15 K (Fig. S7). Altogether, these results lead us to conclude that Dy is a single atom magnet atop O-site of MgO, even in the limit of vanishing magnetic field. The observed magnetic stability is supported by our multiplet analysis which indicates that the g-factor is essentially uniaxial with negligible transverse component (see Supplementary section 8).

Finally, we demonstrate the versatility of Dy single-atom magnets by combining their long-term magnetic stability with the ability to control their spin state by high-energy tunnelling electrons. To illustrate this, we measure tip-field sweep ESR at Bext = 0 T on the Fe sensor with increasing number of surrounding Dy atoms (N), as presented in Fig. 4a. These Fe–DyN structures are built by positioning one Dy atom at a time at fixed Fe–Dy distance of 1.15 nm (Fig. S6). Subsequently, we prepare their magnetic states into spin down configurations in a site selective manner by injecting high-energy tunnelling electrons (Vdc > 150 mV). Thus the total magnetic dipolar field on the sensor Fe atom increases in structures with higher number of Dy atoms, resulting in larger separations between the two resonance peaks (Fig. 4a). Furthermore, selective manipulations of individual Dy spins in Fe–Dy4 also allow us to modify the total magnetic field on the sensor Fe atom (Fig. 4b). Consequently, the separation between the two ESR peaks varies within ≈±25 mT (Fig. 4d). As illustrated in Fig. 4c, d, both approaches lead to a linear increase of the total magnetic dipolar field with the number of Dy atoms, which can be additionally tuned by their relative spin-orientation, thus allowing unique local controls of atomic scale magnetic fields. Such deterministic and local control of magnetic fields can be highly desirable as atomic gates for nanoscale logic devices31, as well as for surface-based quantum architectures. In addition, interacting Dy spin-centres within a surface-based quantum network can exhibit collective magnetic behaviour with high blocking temperature and slow magnetic relaxation, similar to lanthanide-based single-chain magnets14,15.

## Methods

### Sample preparation

The Ag(001) surface was prepared by several cycles of sputtering and annealing. For subsequent MgO growth, the crystal was heated to 700 K and exposed to Mg from a crucible evaporator in an oxygen partial pressure of 1 × 10−6 mbar. Under these conditions, 40 min exposure yields an average of two monolayers of MgO. Next, the sample was cooled down to room temperature within 15 min, and was transferred to the cold STM (4 K). Prior to single atom deposition, the sample manipulator was pre-cooled by touching the sample for 20 min. Subsequently, the sample was quickly taken into an exchange chamber, where depositions of Fe and Dy were performed within a few seconds on to the cold sample using an electron beam evaporator and at a base pressure of <7 × 10−10 mbar. For STM measurements we used a PtIr tip, with a tip apex presumably silver-coated due to repeated indentation into the silver substrate for tip preparation. Tunnelling bias voltages were applied to the tip, however, the Vdc values are expressed with an additional negative sign, i.e., with respect to the sample, as it is conventionally done.

### ESR measurements

For the ESR measurements17, an RF generator (Keysight E8257D) was used to generate the radio frequency signal, which was subsequently added to the DC bias voltage using a bias-tee (SigaTek SB15D2) located outside of the vacuum chamber. A lock-in amplifier (Stanford Research Systems SR860) operating with on-off modulation at 95 Hz was used for signal detection. For conducting the tip-field sweep ESR, the RF-generator was fixed at a constant frequency and output power. Next, the STM feedback loop was kept engaged with low feedback gain and the tunnel current set point was swept. Consequently, the tip–sample distance was swept while the lockin-signal was monitored.

Note that the tip-field sweep ESR measurements are typically performed in strong tip-field regimes satisfying Btip > BDy + Bext. Thus, for Fe atoms in Fe–Dy pairs, the generic resonance condition can be written as

$$\frac{h{f}_{0}}{2{\mu }_{{\rm{Fe}}}}=\left\{\begin{array}{ll}| {B}_{{\rm{tip}}}| +| {B}_{{\rm{Dy}}}+{B}_{{\rm{ext}}}| ,&\,{\text{if}}\,{B}_{{\rm{tip}}}({B}_{{\rm{Dy}}}+{B}_{{\rm{ext}}})\, > \, 0\\ | {B}_{{\rm{tip}}}| -| {B}_{{\rm{Dy}}}+{B}_{{\rm{ext}}}| ,&\,{\text{if}}\,{B}_{{\rm{tip}}}({B}_{{\rm{Dy}}}+{B}_{{\rm{ext}}})\, <\, 0\end{array}\right.$$
(2)

Given its stable magnetic orientation, the Dy atom induces a constant dipolar magnetic field on the Fe sensor. This results in two resonance peaks for all values of Bext used in this work, except for the merging points, i.e., Bext = −BDy. In contrast to the case of Dy atoms, Fe atoms on MgO exhibit significantly shorter magnetic lifetimes24. Following Eq. (2), this gives rise to a maximum of four ESR peaks for Fe atoms in Fe–Fe pairs as shown in Supplementary section 4.

### Fitting ESR peaks

In order to determine the position of the resonance during the tip-field sweeps, we fit the experimental data shown in Fig. 2b, 3a, and 4a, b to a Fano–Lorentzian of the form

$${{\Delta }}I={I}_{{\rm{peak}}}\times \frac{1}{{q}^{2}+1}\times \frac{{(1+\delta \times q)}^{2}}{1+{\delta }^{2}}$$
(3)

Here, Ipeak is the amplitude at the resonant tunnelling current and q is the Fano factor, arising from an additional homodyne detection of ESR32. In addition, $$\delta =\frac{{B}_{{\rm{tip}}}-{B}_{0}}{\tau /2}$$, where τis the linewidth of the peak and B0 is the tip magnetic field for which the resonance occurs in an isolated Fe atom. The ESR signal was always normalized to the set point tunnel current for comparison. Finally for all datasets a polynomial background of degree 2 was subtracted, since the signal intensity increases with tunnel current, due to an increase of the number of read-out tunnel current electrons.