<sec>Rechargeable lithium-ion batteries as the main energy storage equipment should possess high power density, excellent reversible capacity, and long cycle life. However, due to the high cost and dendrite growth of Li, searching for non-Li-ion batteries is urgent. Compared with lithium, magnesium has abundant resources, small ionic radius, and high energy density. Therefore, magnesium-ion batteries (MIBs) can serve as the next generation metal-ion batteries. Two-dimensional materials based on Be or B element acting as the anode of metal-ion batteries always exhibit high theoretical storage capacity. Using first-principles calculations, we systematically explore the potential of BeB<sub>2</sub> as MIBs anode. The optimized BeB<sub>2</sub> monolayer structure shown in Fig. (a) consists of two atomic layers, where each Be atom is coordinated with six B atoms, and each B atom is coordinated with three Be atoms.</sec><sec>The lattice constants are <i>a</i> = <i>b</i> = 3.037 Å with a thickness of 0.554 Å. From the phonon spectrum calculations, the absence of imaginary modes indicates the dynamic stability of BeB<sub>2</sub> monolayer. The presence of a Dirac cone further suggests the excellent conductivity (Fig.(b)). Three stable adsorption sites (Be<sub>1</sub>: top of Be atoms; Be<sub>2</sub> and B<sub>2</sub>: bottom of Be and B atoms) are labeled in Fig. (a). Taking symmetry into account, we consider three pathways to evaluate the migration of Mg atom on BeB<sub>2</sub> monolayer (Fig.(c)). The corresponding lowest diffusion energy barrier is 0.04 eV along Path III. The stable configuration with the maximum adsorption Mg concentration is shown in Fig.(d), which generates a theoretical capacity of 5250 mA·h·g<sup>–1</sup>. The calculated average open-circuit voltage is 0.33 V. Based on <i>ab initio</i> molecular dynamics simulations, the total energy of BeB<sub>2,</sub> with Mg adsorbed, fluctuates within a narrow range, suggesting that BeB<sub>2</sub> can sustain structural stability after storing Mg at room temperature (Fig.(e)). Finally, for practical application, we investigate the adsorption and diffusion behavior of Mg on bilayer BeB<sub>2</sub>. Three configurations are considered: <i>AA</i> stacking (overlapping of Be atoms in upper layer with Be atoms in lower layer), <i>AB</i> stacking (overlapping of Be atoms in upper layer with B atoms in lower layer), and <i>AC</i> stacking (overlapping of Be atoms in upper layer with B—B bonds in lower layer). The most stable configuration is <i>AB</i> stacking (shown in Fig.(f)) with the interlayer spacing of 3.12 Å and the binding energy of –120.97 meV/atom. Comparing with the BeB<sub>2</sub> monolayer structure, the adsorption energy of Mg is –2.24 eV for Be<sub>1</sub>, –1.38 eV for B<sub>5</sub> site, and –1.90 eV for B<sub>4</sub> site, while the lowest diffusion energy barrier is 0.13 eV along the path of B<sub>5</sub>-Be<sub>3</sub>-B<sub>5</sub>. Therefore, according to the above-mentioned properties, we believe that BeB<sub>2</sub> monolayer can serve as an excellent MIBs anode material.</sec>