<Context>. We report on near-infrared (IR) observations of the three anomalous X-ray pulsars XTE J1810-197, 1RXS J1708-4009, 1E 1841-045 and the soft gamma-ray repeater SGR 1900+14, taken with the ESO-VLT, the Gemini, and the CFHT telescopes. <Aims>. This work is aimed at identifying and/or confirming the IR counterparts of these magnetars, as well as at measuring their possible IR variability. <Methods>. In order to perform photometry of objects as faint as Ks~20, we have used data taken with the largest telescopes, equipped with the most advanced IR detectors and in most of the cases with Adaptive Optics devices. The latter are critical to achieve the sharp spatial accuracy required to pinpoint faint objects in crowded fields. <Results>. We confirm with high confidence the identification of the IR counterpart to XTE J1810-197, and its IR variability. For 1E 1841-045 and SGR 1900+14 we propose two candidate IR counterparts based on the detection of IR variability. For 1RXS J1708-4009 we show that none of the potential counterparts within the source X-ray error circle can be yet convincingly associated with this AXP. <Conclusions>. The IR variability of the AXP XTE J1810-197 does not follow the same monotonic decrease of its post-outburst X-ray emission. Instead, the IR variability appears more similar to the one observed in radio band, although simultaneous IR and radio observations are crucial to draw any conclusion in this respect. For 1E 1841-045 and SGR 1900+14, follow-up observations are needed to confirm our proposed candidates with higher confidence.