Land at Tycroes Primary School near Ammanford, Carmarthenshire, was needed for a new building for pupils.
But the grassland habitat had such high ecological value, it has been uprooted and moved to the National Botanic Garden of Wales.
Consultant Richard Pryce — a trustee at the botanic garden — said: "The school field is a significant area of pristine purple-moor grass-rush pasture, a habitat of principal importance for conservation of biological diversity in Wales.
"It contains species including meadow thistle, devil's-bit scabious and Carmarthenshire's county plant, whorled caraway."
A small area of turf was also transplanted by hand into the school conservation area for the pupils to study.
Subscribe to Horticulture Week for more news, more in-depth features and more technical and market info.