The rheology of two- or three-phase magmas has been the focus of much interest because it controls magma ascent and eruption behavior. Research on magma rheology has typically considered homogeneous flow. Here we demonstrate, based on natural examples, that strain resulting from viscous flow preceding explosive fragmentation localizes into shear zones at a microscopic scale. Strain localization affects the rheological behavior of magmas, modifying predictions based on experiments. Localization leads to high-strain-rate shear zones, where elongated, sheared vesicles and shear heating have a weakening effect, surrounding regions of relatively low strain rate, where subequant vesicles have a strengthening effect. Thus, energy is dissipated more efficiently into localized bands, where strain rate increases through feedback effects and can lead to melt fragmentation.