We present the largest near-infrared ( NIR ) data sets , JHK _ { S } , ever collected for classical Cepheids in the Magellanic Clouds ( MCs ) . We selected fundamental ( FU ) and first overtone ( FO ) pulsators , and found 4150 ( 2571Â FU , 1579Â FO ) Cepheids for Small Magellanic Cloud ( SMC ) and 3042 ( 1840Â FU , 1202Â FO ) for Large Magellanic Cloud ( LMC ) . Current sample is 2–3 times larger than any sample used in previous investigations with NIR photometry . We also discuss optical VI photometry from OGLE-III . NIR and optical–NIR Period-Wesenheit ( PW ) relations are linear over the entire period range ( 0.0 < \log P _ { FU } \leq 1.65 ) and their slopes are , within the intrinsic dispersions , common between the MCs . These are consistent with recent results from pulsation models and observations suggesting that the PW relations are minimally affected by the metal content . The new FU and FO PW relations were calibrated using a sample of Galactic Cepheids with distances based on trigonometric parallaxes and Cepheid pulsation models . By using FU Cepheids we found a true distance moduli of 18.45 \pm 0.02 { ( random ) } \pm 0.10 { ( systematic ) } Â mag ( LMC ) and 18.93 \pm 0.02 { ( random ) } \pm 0.10 { ( systematic ) } Â mag ( SMC ) . These estimates are the weighted mean over 10 PW relations and the systematic errors account for uncertainties in the zero–point and in the reddening law . We found similar distances using FO Cepheids ( 18.60 \pm 0.03 { ( random ) } \pm 0.10 { ( systematic ) } Â mag [ LMC ] and 19.12 \pm 0.03 { ( random ) } \pm 0.10 { ( systematic ) } Â mag [ SMC ] ) . These new MC distances lead to the relative distance , \Delta \mu = 0.48 \pm 0.03 Â mag ( FU , \log P = 1 ) and \Delta \mu = 0.52 \pm 0.03 Â mag ( FO , \log P = 0.5 ) , which agrees quite well with previous estimates based on robust distance indicators .