The accretion flow around X-ray pulsars with a strong magnetic field is funnelled by the field to relatively small regions close to the magnetic poles of the neutron star (NS), the hotspots. During strong outbursts regularly observed from some X-ray pulsars, the X-ray luminosity can be so high, that the emerging radiation is able to stop the accreting matter above the surface via radiation-dominated shock, and the accretion column begins to rise. This border luminosity is usually called the critical luminosity. Here we calculate the critical luminosity as a function of the NS magnetic field strength $B$ using exact Compton scattering cross section in strong magnetic field. Influence of the resonant scattering and photon polarization is taken into account for the first time. We show that the critical luminosity is not a monotonic function of the B-field. It reaches a minimum of a few 10^{36} erg s^{-1} when the cyclotron energy is about 10 keV and a considerable amount of photons from a hotspot have energy close to the cyclotron resonance. For small B, this luminosity is about 10^{37} erg s^{-1}, nearly independent of the parameters. It grows for the B-field in excess of 10^{12} G because of the drop in the effective cross-section of interaction below the cyclotron energy. We investigate how different types of the accretion flow and geometries of the accretion channel affect the results and demonstrate that the general behaviour of the critical luminosity on B-field is very robust. The obtained results are shown to be in a good agreement with the available observational data and provide a necessary ground for the interpretation of upcoming high quality data from the currently operating and planned X-ray telescopes.