We present H- and K-band spectroscopy of OB and Wolf–Rayet (WR) members of the Milky Way cluster 1806−20 (G10.0–0.3) to obtain a revised cluster distance, of relevance to the 2004 giant flare from the (soft gamma repeater) SGR 1806−20 magnetar. From GNIRS (Gemini Near-Infrared Spectrograph) spectroscopy obtained with Gemini South, four candidate OB stars are confirmed as late O/early B supergiants, while we support previous mid-WN and late WC classifications for two WR stars. Based upon an absolute Ks-band magnitude calibration for B supergiants and WR stars, and near-infrared (IR) photometry from NIRI (Near-Infrared Imager) at Gemini North plus archival VLT/ISAAC (Very Large Telescope/Infrared Spectrometer And Array Camera) data sets, we obtain a cluster distance modulus of 14.7 ± 0.35 mag. The known stellar content of the 1806−20 cluster suggests an age of 3–5 Myr, from which theoretical isochrone fits infer a distance modulus of 14.7 ± 0.7 mag. Together, our results favour a distance modulus of 14.7 ± 0.4 mag (8.7+1.8−1.5 kpc) to the 1806−20 cluster, which is significantly lower than the nominal 15 kpc distance to the magnetar. For our preferred distance, the peak luminosity of the 2004 December giant flare is reduced by a factor of 3 to 7 × 1046 erg s−1, such that the contamination of BATSE (Burst And Transient Source Experiment) short gamma-ray bursts (GRBs) from giant flares of extragalactic magnetars is reduced to a few per cent. We infer a magnetar progenitor mass of ∼48+20−8 M⊙, in close agreement with that obtained recently for the magnetar in Westerlund 1.