The novel green magnetic phosphonated-functionalized sporopollenin nanocomposite (MPSP-nanocomposite) was synthetized and used for stir bar sorptive dispersive microextraction (SBSDME) of melamine in milk and milk-based food products. TEM, SEM-EDX, FT-IR, VSM techniques were applied for characterization of MPSP-nanocomposite. The influential parameters including pH, extraction time, stirring rate, elution solvent type and volume, sample volume, desorption time, and ionic strength were studied and at optimum conditions, the linear range of 1–500 (µg L−1), the LOD (S/N = 3) of 0.30 (µg L−1), and the LOQ (S/N = 10) of 0.95 (µg L−1) were achieved. The intra-day precision values (RSD (%), n = 7) of 3.5% for the melamine concentration of 25 (µg L−1). The relative recoveries of 95.8% to 99.6% were acquired for the real samples which confirmed that the proposed method could be successfully utilized in complex matrixes with high matrix effects.