A nonlinear electromagnetic scattering problem is studied in the presence of bound states in the radiation
continuum (or resonances with the vanishing width). It is shown that the solution is not analytic in the nonlinear
susceptibility and the conventional perturbation theory fails due to strong evanescent fields that necessarily occur
if the scattering system has resonances with the vanishing width. A non-perturbative approach is developed. It
is then applied to the system of two parallel periodic subwavelength arrays of dielectric cylinders with a second
order nonlinear susceptibility. This scattering system is known to have bound states in the radiation continuum.
In particular, it is demonstrated that, for a wide range of values of the nonlinear susceptibility, the structure
converts over 40% of the incident fundamental harmonic flux into the outgoing second harmonic flux when the
distance between the arrays is as low as a half of the incident radiation wavelength. The effect is non-perturbative
and solely attributed to the presence of bound states in the radiation continuum. The example demonstrates that
bounds states in the radiation continuum can be used to substantially enhance and control optically nonlinear
effects in nanophotonic devices.