The binary compound Mg3Sb2 (also written as MgMg2Sb2) exhibits a much lower lattice thermal conductivity ( κ L ) than its ternary analog CaMg2Sb2, despite its relatively low mass density and simple crystalline structure. Here, we perform a comparative first-principles study of the lattice dynamics in MgMg2Sb2 and CaMg2Sb2 based on the density functional theory, together with the self-consistent phonon theory and the Boltzmann transport theory. We show that the modest anharmonicity of CaMg2Sb2 renders the three-phonon processes dominant, and the temperature dependence of κL approximately follows the T − 1 relationship. In contrast, the strong quartic anharmonicity of MgMg2Sb2 leads to the ultralow κL and weak temperature dependence, in agreement with the experimental observations. A comprehensive analysis reveals that the κ L s in the two compounds are mainly carried by the acoustic phonons associated with the Sb atoms, and the different behaviors of κ L result from the chemical bond changes around Sb atoms, which bond more covalently with the Mg atoms than the Ca atoms and thus lead to high-order anharmonicity in MgMg2Sb2. These results give us insights into the understanding of the anomalous thermal transport in thermoelectric materials. [ABSTRACT FROM AUTHOR]