With the aim of developing polymeric gels sensitive to external stimuli and able to reversibly adsorb and release divalent ions, copolymer gels of N-isopropylacrylamide (NIPA) and methacrylic (MAA) monomers were prepared. We chose calcium as a target divalent ion. Two MAAs form a complex with a calcium ion, and the NIPA component allows the polymers to swell and shrink reversibly in response to temperature. The adsorbing site develops an affinity to target ions when the adsorbing molecules come into proximity, but when they are separated, the affinity diminishes. To enhance the affinity to calcium, an imprinting technique was applied using Ca2+ and Pb2+ ions as templates in methylsulfoxide and dioxane media, respectively. The adsorption capacity of the imprinted gels was compared with that of the nonimprinted gels, and the effects of the templates, the solvents, and the amount of methacrylic monomers used in the synthesis and the medium temperature over the Ca2+ adsorption capacity of the gels from aqueous solutions were evaluated. The analysis of the adsorption revealed that (a) the adsorption can be described by the Langmuir isotherms; (b) there is an approximately linear relationship between saturation and methacrylic monomer concentration; (c) the affinity depends on the degree of gel swelling or shrinkage that can be switched on and off by temperature; (d) in the shrunken state, the affinity depends approximately linearly on the MAA concentration in the imprinted gels, whereas in the nonimprinted gels it is proportional to the square of MAA concentration; (e) the imprinted gels adsorb more than the nonimprinted gels when MAA concentration is less than that of permanent cross linkers. The success of imprinting of CaMAA(2) and PbMAA(2) complex is evidence for memory of such complex onto the weakly cross-linked gel. (C) 2001 American Institute of Physics.