Coastal lagoons are complex systems, with considerable habitat heterogeneity and often subject to high temporal dynamics, which constitutes a great challenge for ecological assessment programs. For defining reference conditions for benthic invertebrates, under the EU Water Framework Directive objectives, historical data from the Ria Formosa leaky lagoon (wet surface area of about 105 km 2 ) located in Southern Portugal was used. The influence of habitat features, such as channel depth, sediment type and seagrass cover, on the expression of these biological communities was inferred by analysing subtidal data collected at stations with different environmental characteristics. Such heterogeneity effect was analysed at the community compositional and structural levels, and also for three indices included in a multimetric Benthic Assessment Tool (BAT). This tool for the assessment of ecological status includes the Margalef index, Shannon-Wiener diversity index, and AZTI's Marine Biotic Index (AMBI). Significant variations associated with environmental features were reflected on specific reference conditions at four habitats in the lagoon. After habitat calibration, the Benthic Assessment Tool (BAT) revealed that, in general and for the period of time covered by this historical data set, the status of the lagoon corresponded to a good ecological condition, which is mainly due to its high water renewal rate. Such classification is in accordance with the majority of studies at the lagoon. However, at punctual sites with human induced high water residence times, significantly lower BAT values were registered. Such community degradation can be associated with physical stress due to salinity increase and to a degradation of water quality, with occurrence of occasional dystrophic crisis, triggered by low water renewal. Habitat 2 differentiation was a crucial step for a correct evaluation of the ecological condition of invertebrate communities across the lagoonal system.