Context : Aims : We study the evolution of the luminosity function ( LF ) of type-1 and type-2 Active Galactic Nuclei ( AGN ) in the mid-infrared , and then derive the contribution of the AGN to the Cosmic InfraRed Background ( CIRB ) and the expected source counts to be observed by S pitzer at 24 \mu m . Methods : We used a sample of type-1 and type-2 AGN selected at 15 \mu m ( ISO ) and 12 \mu m ( IRAS ) , and classified on the basis of their optical spectra . Local spectral templates of type-1 and type-2 AGN have been used to derive the intrinsic 15 \mu m luminosities . We adopted an evolving smooth two-power law shape of the LF , whose parameters have been derived using an un-binned maximum likelihood method . Results : We find that the LF of type-1 AGN is compatible with a pure luminosity evolution ( L ( z ) = L ( 0 ) ( 1 + z ) ^ { k _ { L } } ) model where k _ { L } \sim 2.9 . A small flattening of the faint ( L _ { 15 } < L ^ { * } _ { 15 } ) slope of the LF with increasing redshift is favoured by the data . A similar evolutionary scenario is found for the type-2 population with a rate k _ { L } ranging from \sim 1.8 to 2.6 , depending significantly on the adopted mid-infrared spectral energy distribution . Also for type-2 AGN a flattening of the LF with increasing redshift is suggested by the data , possibly caused by the loss of a fraction of type-2 AGN hidden within the optically classified starburst and normal galaxies . The type-1 AGN contribution to the CIRB at 15 \mu m is ( 4.2–12.1 ) \times 10 ^ { -11 } \mathrm { Wm ^ { -2 } sr ^ { -1 } } , while the type-2 AGN contribution is ( 5.5–11.0 ) \times 10 ^ { -11 } \mathrm { W m ^ { -2 } sr ^ { -1 } } . We expect that S pitzer will observe , down to a flux limit of S _ { 24 \mu \mathrm { m } } =0.01 mJy , a density of \sim 1200 deg ^ { -2 } type-1 and \sim 1000 deg ^ { -2 } type-2 optically classified AGN . Conclusions : AGN evolve in the mid-infrared with a rate similar to the ones found in the optical and X–rays bands . The derived total contribution of the AGN to the CIRB ( 4-10 % ) and S pitzer counts should be considered as lower limits , because of a possible loss of type-2 sources caused by the optical classification .