  We introduce a multi-scale diagonalization scheme to study the transition
between the many-body localized and the ergodic phase in disordered quantum
chains. The scheme assumes a sharp dichotomy between subsystems that behave as
localized and resonant spots that obey the Eigenstate Thermalization Hypothesis
(ETH). We establish a set of microscopic principles defining the
diagonalization scheme, and use them to numerically study the transition in
very large systems. To a large extent the results are in agreement with an
analytically tractable mean-field analysis of the scheme: We find that at the
critical point the system is almost surely localized in the thermodynamic
limit, hosting a set of thermal inclusions whose sizes are power-law
distributed. On the localized side the {\em typical} localization length is
bounded from above. The bound saturates upon approach to criticality, entailing
that a finite ergodic inclusion thermalizes a region of diverging diameter. The
dominant thermal inclusions have a fractal structure, implying that averaged
correlators decay as stretched exponentials throughout the localized phase.
Slightly on the ergodic side thermalization occurs through an avalanche
instability of the nearly localized bulk, whereby rare, supercritically large
ergodic spots eventually thermalize the entire sample. Their size diverges at
the transition, while their density vanishes. The non-local, avalanche-like
nature of this instability entails a breakdown of single parameter scaling and
puts the delocalization transition outside the realm of standard critical
phenomena.
