Context. Gamma-ray burst (GRBs) afterglows probe sightlines to star-forming regions in distant star-forming galaxies. Here we present a study of the peculiar afterglow spectrum of the z = 0.889 Swift GRB 140506A. Aims. Our aim is to understand the origin of the very unusual properties of the absorption along the line-of-sight. Methods. We analyse spectroscopic observations obtained with the X-shooter spectrograph mounted on the ESO/VLT at two epochs 8.8 h and 33 h after the burst as well as imaging from the GROND instrument. We also present imaging and spectroscopy of the host galaxy obtained with the Magellan telescope. Results. The underlying afterglow appears to be a typical afterglow of a long-duration GRB. However, the material along the line-of- sight has imprinted very unusual features on the spectrum. Firstly, there is a very broad and strong flux drop below 8000 AA (4000 AA in the rest frame), which seems to be variable between the two spectroscopic epochs. We can reproduce the flux-drops both as a giant 2175 AA extinction bump and as an effect of multiple scattering on dust grains in a dense environment. Secondly, we detect absorption lines from excited H i and He i. We also detect molecular absorption from CH+ . Conclusions. We interpret the unusual properties of these spectra as reflecting the presence of three distinct regions along the line-of-sight: the excited He i absorption originates from an H ii-region, whereas the Balmer absorption must originate from an associated photodissociation region. The strong metal line and molecular absorption and the dust extinction must originate from a third, cooler region along the line-of-sight. The presence of (at least) three separate regions is reflected in the fact that the different absorption components have different velocities relative to the systemic redshift of the host galaxy.