The spectral flow is a classical notion of functional analysis and differential geometry which was given different interpretations as Fredholm index, Witten index, and Maslov index. The classical theory treats spectral flow outside the essential spectrum. Inside essential spectrum, the spectral shift function could be considered as a proper analogue of spectral flow, but unlike the spectral flow, the spectral shift function is not an integer-valued function. In this paper it is shown that the notion of spectral flow admits a natural integer-valued extension for a.e. value of the spectral parameter inside essential spectrum too and appropriate theory is developed. The definition of spectral flow inside essential spectrum given in this paper applies to the classical spectral flow and thus gives one more new alternative definition of it.