We present a new near-infrared imaging survey in the four CFHTLS deep fields : the WIRCam Deep Survey or “ WIRDS ” . WIRDS comprises extremely deep , high quality ( FWHM \sim 0.6 \arcsec ) J , H and K _ { s } imaging covering a total effective area of 2.1 { ~ { } deg } ^ { 2 } and reaching AB 50 % completeness limits of \approx 24.5 . We combine our images with the CFHTLS to create a unique eight-band ugrizJHK _ { S } photometric catalogues in the four CFHTLS deep fields ; these four separate fields allow us to make a robust estimate of the effect of cosmic variance for all our measurements . We use these catalogues in combination with \approx 9 , 800 spectroscopic redshifts to estimate precise photometric redshifts ( \sigma _ { \Delta z / ( 1 + z ) } \lesssim 0.03 at i < 25 ) , galaxy types , star-formation rates and stellar masses for a unique sample of \approx 1.8 million galaxies . Our JHK _ { s } number counts are consistent with previous studies . We apply the “ BzK ” selection to our gzK filter set and find that the star forming BzK selection successfully selects 76 % of star-forming galaxies in the redshift range 1.4 < z < 2.5 in our photometric catalogue , based on our photometric redshift measurement . Similarly the passive BzK selection returns 52 % of the passive 1.4 < z < 2.5 population identified in the photometric catalogue . We present the mass functions of the total galaxy population as a function of redshift up to z = 2 and present fits using double Schechter functions . A mass-dependent evolution of the mass function is seen with the numbers of galaxies with masses of M \lesssim 10 ^ { 10.75 } still evolving at z \lesssim 1 , but galaxies of higher mass reaching their present day numbers by z \sim 0.8 - 1 . This is consistent with the present picture of downsizing in galaxy evolution . We compare our results with the predictions of the GALFORM semi-analytical galaxy formation model and find that the simulations provide a relatively successful fit to the observed mass functions at intermediate masses ( i.e . 10 \lesssim { log } ( M / M _ { \odot } ) \lesssim 11 ) . However , as is common with semi-analytical predictions of the mass function , the GALFORM results under-predict the mass function at low masses ( i.e . { log } ( M / M _ { \odot } ) \lesssim 10 ) , whilst the fit as a whole degrades beyond redshifts of z \sim 1.2 . All photometric catalogues and images are made publicly available from TERAPIX and CADC .