Afatoxins are a kind of mycotoxins that are mostly produced by a group of molds such as Aspergillus favus and Aspergillus parasiticus. The studies on diferent parts of Iran showed that AFM1 infection of milk is higher than European Union’s standard. In this study, the specifc aptamer with the carboxylic group at the end of 5′ and Fe3O4 nanoparticles with amine groups was synthesized. Morphological and structural qualities of Fe3O4 were determined by the Fourier-transform infrared spectrograph (FTIR), dynamic light scattering, scanning electron microscope, and X-ray difraction devices. The specifcity of the aptamer to AFM1 was investigated in adjacent of AFM1 and afatoxin B1. Then, aptamers were attached to nanoparticles to improve synthetic qualities and to ease of its detachment. The attachment was approved by FTIR method. The complex (Fe3O4–APT) was then added to infected milk and after the proper time was detached from the milk using a magnet. The remained amount of AFM1 was attained in milk using high-performance liquid chromatography. Our result showed that this method for afatoxin detoxifcation is much more efective than conventional methods based on recognition of AFM1 and their concentration in infected milk. This method is more applicable, faster, and cheaper highlighting its application in milk factories.