In this study, magnetic molecularly imprinted polymers (MMIPs) with enhanced selectivity were synthesized using sulfamethazine (SMZ) as template molecule and hydrophilic triethylene glycol dimethacrylate as cross-linker. Compared with that of imprinted polymers ([email protected]) prepared with commonly used ethylene glycol dimethacrylate, MMIPs with increased hydrophilicity could achieve efficient adsorption and preferred binding ability for template SMZ (selectivity factor increased from 0.9 of [email protected] to 1.9) in the presence of structural analogues with significant similarities (i.e. sulfamonomethoxine). Under the optimal extraction conditions, the developed MMIPs-MSPE-HPLC-DAD method showed wide linear range (1.6–250 μg/L), low detection limit (0.44 μg/L) and satisfactory precision (RSD < 7%). The proposed strategy offers a potential and simple way to obtain imprinted polymers with high recognition capability, providing a perspective method in the accurate determination of SMZ in environmental water.