Context. Westerlund 1 is a young, massive Galactic starburst cluster that contains a rich coeval population of Wolf-Rayet stars, hot- and cool-phase transitional supergiants, and a magnetar. Aims. We use spectroscopic and photometric observations of the eclipsing double-lined binary W13 to derive dynamical masses for the two components, in order to determine limits for the progenitor masses of the magnetar CXOU J164710.2-455216 and the population of evolved stars in Wd1. Methods. We use eleven epochs of high-resolution VLT/FLAMES spectroscopy to construct a radial velocity curve for W13. R-band photometry is used to constrain the inclination of the system. Results. W13 has an orbital period of 9.2709 ± 0.0015 days and near-contact configuration. The shallow photometric eclipse rules out an inclination greater than 65°, leading to lower limits for the masses of the emission-line optical primary and supergiant optical secondary of 21.4 ± 2.6 M⊙ and 32.8 ± 4.0 M⊙ respectively, rising to 23.2-3.0+3.3 M⊙ and 35.4-4.6+5.0 M ⊙ for our best-fit inclination 62-4+3 degrees. Comparison with theoretical models of Wolf-Rayet binary evolution suggest the emission-line object had an initial mass in excess of ∼35 M ⊙, with the most likely model featuring highly non-conservative late-Case A/Case B mass transfer and an initial mass in excess of 40 M ⊙. Conclusions. This result confirms the high progenitor mass of the magnetar CXOU J164710.2-455216 inferred from its membership in Wd1, and represents the first dynamical constraint on the progenitor mass of any magnetar. The red supergiants in Wd1 must have similar progenitor masses to W13 and are therefore amongst the most massive stars to undergo a red supergiant phase, representing a challenge for population models that suggest stars in this mass range end their redwards evolution as yellow hypergiants. © 2010 ESO.