A rhizomatous perennial herb found on a wide range of calcareous to mildly acidic soils. Its habitats include grassland, woodland, hedgerows, scrub, sand dunes, dune-slacks, limestone pavement and heathland; in Anglesey and Ireland it also grows in fens. It frequently occurs, sometimes as large colonies, on railway embankments and in disused quarries and sand-pits. 0-670 m (Ben Lawers, Mid Perth).
There has been little change in the distribution of this species since the 1962 Atlas, although some lowland sites have been lost to agricultural activities, including ploughing of grassland and hedgerow removal.
Eurosiberian Boreo-temperate element.