A magnetic polyacrylonitrile-melamine nanoadsorbent (PAN-Mel@Fe3O4) has been developed as a polymer-based adsorbent in three steps involving the preparation of polyacrylonitrile (PAN), the modification of PAN with melamine, and the in-situ magnetization of the PAN-Mel nanocomposite. During the fabrication of PAN-Mel@Fe3O4 nanocomposite, various analyses were used to investigate its physicochemical properties. The PAN-Mel@Fe3O4 nanoadsorbent was investigated to be able to efficiently adsorb cadmium (Cd) and lead (Pb) from aqueous media. Several experimental conditions were employed for evaluating adsorption performance, involving pH of medium, adsorbent dosage, contact time, and initial contaminant concentration. Therefore, the Cd (II) and Pb (II) maximum adsorption capacity (Qmax) in the optimized conditions reached 454.54 and 416.66 mg/g, respectively. The experimental adsorption data for both studied heavy metals was fitted well by the Freundlich isotherm model and adsorption kinetics for both heavy metals descriptions satisfactorily by the pseudo-second-order model. The PAN-Mel@Fe3O4 adsorbs mainly Cd (II) and Pb (II) by electrostatic interaction due to a great number of the nitrogen-rich bidentate chelating ligands. Regarding the adsorption–desorption of the PAN-Mel@Fe3O4 nanoadsorbent, after recycling it four times, no significant decrease in its efficiency was observed and it could be used for the four time as well.