In the present study, the magnetic NH2-MIL-101(Al)/chitosan nanocomposite (MIL/Cs@Fe3O4 NCs) was synthesized and used in the removal of azithromycin (AZT) from an aqueous solution for the first time. The as-synthesized MIL/Cs@Fe3O4 NCs was characterized by SEM, TEM, XRD, FTIR, BET, and VSM techniques. The effect of various key factors in the AZT adsorption process was modeled and optimized using response surface methodology based on central composite design (RSM-CCD). The low value of p-value (1.3101e−06) and RSD (1.873) parameters, along with the coefficient of determination > 0.997 implied that the developed model was well fitted with experimental data. Under the optimized conditions, including pH: 7.992, adsorbent dose: 0.279 g/L, time: 64.256 min and AZT concentration: 10.107 mg/L, removal efficiency and AZT adsorption capacity were obtained as 98.362 ± 3.24% and 238.553 mg/g, respectively. The fitting of data with the Langmuir isotherm (R2: 0.998, X2: 0.011) and Pseudo-second-order kinetics (R2: 0.999, X2: 0.013) showed that the adsorption process is monolayer and chemical in nature. ΔH° > 0, ΔS° > 0, and ∆G° < 0 indicated that AZT removal was spontaneous and endothermic in nature. The effect of Magnesium on AZT adsorption was more complicated than other background ions. Reuse of the adsorbent in 10 consecutive experiments showed that removal efficiency was reduced by about 30.24%. The performance of MIL/Cs@Fe3O4 NCs under real conditions was also tested and promising results were achieved, except in the treatment of AZT from raw wastewater.