Magnetars are a special class of slowly rotating neutron stars with extremely strong magnetic fields -- at least an order of magnitude larger than those of the normal radio pulsars. The potential evolutionary links and differences between these two types of objects are still unknown; recent studies, however, have provided circumstantial evidence connecting magnetars with very massive progenitor stars. Here we report the discovery of an infrared elliptical ring or shell surrounding the magnetar SGR 1900+14. The appearance and energetics of the ring are difficult to interpret within the framework of the progenitors stellar mass loss or the subsequent evolution of the supernova remnant. We suggest instead that a dust-free cavity was produced in the magnetar environment by the giant flare emitted by the source in August 1998. Considering the total energy released in the flare, the theoretical dust--destruction radius matches well with the observed dimensions of the ring. We conclude that SGR 1900+14 is unambiguously associated with a cluster of massive stars, thereby solidifying the link between magnetars and massive stars.