This article reports a spectrofluorometric method for the determination of sunitinib (STB) drug based on molecularly imprinted nanofibers fabricated by the electrospinning method and modified by magnetic nanoparticles as sorbent. The characterization of magnetic molecularly imprinted nanofibers (MMINs) was carried out using X-ray diffraction (XRD), scanning electron microscope (SEM), and transmission electron microscopy (TEM), which confirmed the successful synthesis of MMINs with well-distributed magnetite nanoparticles. Drug adsorption and desorption were optimized and important parameters such as sample pH, nanofiber mass, adsorption and desorption time, eluent solvent and sample volume were analyzed. The results demonstrated that the MMINs act as a selective sorbent for STB and can be readily collected through an external magnetic field. Methanol was used as the best eluent solvent for STB desorption from MNIN. A linear correlation was observed between the STB concentrations and fluorescence intensities in the range of 0.01–15.0 mg L−1. The detection limit for this method was 0.002 mg L−1. The relative standard deviation (RSD) of 2.6 % for 1.0 mg L−1 and 1.1 % for 10 mg L−1 of STB (n = 3) were obtained, which indicates that the developed method is precise in determining STB. Human serum and capsule analysis show the applicability of the proposed sensor for real samples.