The G305 H ii complex (G305.4+0.1) is one of the most massive star-forming structures yet identified within the Galaxy. It is host to many massive stars at all stages of formation and evolution, from embedded molecular cores to post-main-sequence stars. Here, we present a detailed near-infrared analysis of the two central star clusters Danks 1 and Danks 2, using Hubble Space Telescope+NICMOS imaging and Very Large Telescope+ISAAC spectroscopy. We find that the spectrophotometric distance to the clusters is consistent with the kinematic distance to the G305 complex, an average of all measurements giving a distance of 3.8 ± 0.6 kpc. From analysis of the stellar populations and the pre-main-sequence stars, we find that Danks 2 is the elder of the two clusters, with an age of 3+3− 1 Myr. Danks 1 is clearly younger with an age of 1.5+1.5− 0.5 Myr, and is dominated by three very luminous H-rich Wolf–Rayet stars which may have masses ≳100 M⊙. The two clusters have mass functions consistent with the Salpeter slope, and total cluster masses of 8000 ± 1500 and 3000 ± 800 M⊙ for Danks 1 and Danks 2, respectively. Danks 1 is significantly the more compact cluster of the two, and is one of the densest clusters in the Galaxy with log (ρ/M⊙ pc−3) = 5.5+0.5− 0.4. In addition to the clusters, there is a population of apparently isolated Wolf–Rayet stars within the molecular cloud’s cavity. Our results suggest that the star-forming history of G305 began with the formation of Danks 2, and subsequently Danks 1, with the origin of the diffuse evolved population currently uncertain. Together, the massive stars at the centre of the G305 region appear to be clearing away what is left of the natal cloud, triggering a further generation of star formation at the cloud’s periphery.