We consider disordered tight-binding models which Greens functions obey the self-consistent cavity equations . Based on these equations and the replica representation, we derive an analytical expression for the fractal dimension D_{1} that distinguishes between the extended ergodic, D_{1}=1, and extended non-ergodic (multifractal), 0<D_{1}<1 states. The latter corresponds to the solution with broken replica symmetry, while the former corresponds to the replica-symmetric solution. We prove the existence of the extended non-ergodic phase in a broad range of disorder strength and energy as well as existence of transition between the two extended phases. The results are applied to the systems with local tree structure (Bethe lattices) and to the systems with infinite connectivity (Rosenzweig-Poter random matrix theory). We obtain the phase diagram in the disorder-energy plain for the Bethe lattice and identify two insulating phases classified by the (one-step) replica symmetry breaking parameter. Finally we express the line of the Anderson localization transition, the stability limit of the non-ergodic extended phase and the line of the first order transitions between the two extended phases in terms of the Lyapunov exponents.