Context : In very young clusters , the stellar age distribution is the empirical proof of the duration of star cluster formation and thus it gives indications of the physical mechanisms involved in the star formation process . Determining the amount of interstellar extinction and the correct reddening law are crucial steps to derive fundamental stellar parameters and in particular accurate ages from the HR diagram . Aims : In this context , we derived accurate stellar ages for NGC 6530 , the young cluster associated with the Lagoon Nebula to infer the star formation history of this region . Methods : We use the Gaia -ESO survey observations of the Lagoon Nebula , together with photometric literature data and Gaia DR2 kinematics , to derive cluster membership and fundamental stellar parameters . Using spectroscopic effective temperatures , we analyze the reddening properties of all objects and derive accurate stellar ages for cluster members . Results : We identified 652 confirmed and 9 probable members . The reddening inferred for members and non-members allows us to distinguish foreground objects , mainly main-sequence ( MS ) stars , and background objects , mainly giants . This classification is in agreement with the distances inferred from Gaia DR2 parallaxes for these objects . The foreground and background stars show a spatial pattern that allows us to trace the three-dimensional structure of the nebular dust component . Finally , we derive stellar ages for 382 confirmed cluster members for which we obtained the individual reddening values . In addition , we find that the gravity-sensitive \gamma index distribution for the M-type stars is correlated with stellar age . Conclusions : For all members with T _ { eff } < 5500 K , the mean logarithmic age is 5.84 ( units of years ) with a dispersion of 0.36 dex . The age distribution of stars with accretion and/or disk ( CTTSe ) is similar to that of stars without accretion and without disk ( WTTSp ) . We interpret this dispersion as evidence of a real age spread since the total uncertainties on age determinations , derived from Monte Carlo simulations , are significantly smaller than the observed spread . This conclusion is supported by the evidence of a decreasing of the gravity-sensitive \gamma index as a function of stellar ages . The presence of a small age spread is also supported by the spatial distribution and the kinematics of old and young members . In particular , members with accretion and/or disk , formed in the last 1 Myr , show evidence of subclustering around the cluster center , in the Hourglass Nebula and in the M8-E region , suggesting a possible triggering of star formation events by the O-type star ionization fronts .