A magnetic solid-phase extraction (M-SPE) procedure on a magnetic phosphorus-containing polymer (M-PhCP) was established for the separation/preconcentration of trace amounts of lead and cadmium in water samples prior to their microsampling flame atomic absorption spectrometric determination. The separation of lead(II) and cadmium(II) adsorbed as 2-(5-bromo-2-pyridylazo)-5-diethylamino-phenol (5-Br-PADAP) chelates on M-PhCP from aqueous solution was simply achieved by applying an external magnetic field via a permanent magnet. The important analytical factors governing the extraction efficiency such as pH, amount of adsorbent, eluent concentration and volume, vortex time, ligand volume, and sample volume were investigated and optimized. The influences of matrix components were also investigated. The limit of detection (LOD) of Pb and Cd was 2.7 and 1.1 mu g L-1, respectively. The accuracy of the proposed method was proved by analysis of the TMDA-64.2 Lake Ontario water and SPS-WW2 waste water certified reference materials and addition-recovery tests. The method was successfully applied for the determination of lead and cadmium in water samples.