A non-linear analysis is presented of localized regions of strong divergence of parallel heat flux-thermal fronts-in the edge and scrape-off layers of tokamaks. The phenomena of divertor detachment and MARFEs are discussed in terms of one dimensional thermal conduction in the parallel co-ordinate, but retaining cross-field transport power divergence and radiation as source terms. A full finite aspect-ratio geometry is retained and has important effects. Thermal fronts are shown to require either localization of the source terms or density control, to be stable against parallel motion. The edge density range over which the front is naturally localized to the divertor leg is shown to be rather small. The size, stability and preferred position of MARFEs are predicted and are in agreement with experiment