It is of great significance to monitor bisphenol A (BPA) in the environment because of its potential environmental and health risks. However, the detection of trace or ultratrace BPA in complicated environmental samples is challenging due to the relatively low affinity and poor selectivity of existing adsorbents used in sample pretreatment. Herein, we report a high-affinity, low environment-dependent and strong interference-resistant abiotic affinity ligand, a N-methacryloyl-l-lysine-NH2 (MLys)-based hydrogel copolymer (HP 17) screened from a small focused polymer library engineered by incorporating various combinations and ratios of candidate functional monomers. The selection of these monomers was guided by molecular mechanism between BPA and the ligand-binding pocket of its estrogen receptors. The BPA–HP17 binding is mainly a synergistic effect of π-cation and hydrophobic interactions. The screened HP 17 has high adsorption capacity (349.4 mg/g) for BPA under wide pH (3.0–10.0) and ionic strength (0–150 mM) range. To improve its practicability, a hydrogel copolymer/Fe3O4 composite microspheres (Fe3O4@HP 17) was synthesized and applied for magnetic solid phase extraction–high-performance liquid chromatography (MSPE–HPLC) analysis of BPA in tap water, lake water and industrial effluents. The method shows wide linear range (2.5⁓100 ng/mL), high sensitivity (detection limit of 0.22 ng/mL even without further concentration after desorption), high accuracies (92.6⁓103.0 %) and good precisions (0.57⁓4.53 %), indicating a great potential of this material and method in the detection of trace or ultratrace BPA in complex environmental water samples.