5-Fluorouracil (5-FU) is a chemotherapy drug that belongs to a class of medications known as antimetabolites and has many applications in cancer therapy, especially in the treatment of gastric cancer. However, high dose of 5-FU in gastric cancer treatment can cause various side effects. Therefore, delivery of this significant drug with a suitable delivery system can significantly improve the safety and efficacy of this drug, leading to better treatment outcomes and improved patient quality of life. Mg-doped ZnO has garnered significant attention in scientific research due to its distinct physicochemical characteristics. This investigation introduces an uncomplicated and economical approach for synthesis of Mg-doped ZnO nanoparticles. Then, the nanoparticles were subjected to thorough analysis employing FT-IR, XRD, XPS, FE-SEM, TEM, UV–Vis, EDS, and DLS techniques. Subsequently, the research explored capacity of the created nanostructure to serve as a nanocarrier for 5-Fluorouracil. Findings indicated an approximately 76 % drug loading capacity that is dependent on pH and duration time. The release profile depicted a gradual release under physiological conditions (pH 7.4, 39 %), contrasting with a notably accelerated release rate at pH 5.3 (82 %) in 48 h. Furthermore, an in vitro assessment of cellular cytotoxicity performed on AGS gastric cancer cell line to evaluate safety and effectiveness of Mg-doped ZnO nanoparticles. Results from MTT assay affirmed the potential of this nanoparticle as a promising vehicle for 5-Fluorouracil delivery.