Optical impact on the spin system in a magnetically ordered medium provides a unique possibility for local manipulation of magnetization at subpicosecond time scales. One of the mechanisms of the optical manipulation is related to the inverse Faraday effect (IFE). Usually the IFE is observed in crystals and magnetic films on a substrate. Here we demonstrate the IFE induced by fs-laser pulses in the magnetic film inside the magnetophotonic microcavity. Spectral dependence of the IFE on the laser pulse wavelength in the band gap of the magnetophotonic microcavity has a sharp peak leading to a significant enhancement of the IFE. This phenomenon is explained by strong confinement of the electromagnetic energy within the magnetic film. Calculated near field distribution of the IFE effective magnetic field indicates its subwavelength localization within 30 nm along the film thickness. These excited volumes can be shifted along the sample depth via e.g. changing frequency of the laser pulses. The obtained results open a way for ultrafast optical control of magnetization at subwavelength scales.