Megaprojects radically change the landscape due to their large-scale and high investments. Forests are often one of the most affected habitats, as they are frequently included in megaproject construction sites. These habitats support rich animal communities that the new settlement may threaten. Among all species present in any construction site, those listed in the Habitats Directive (92/43/CEE) deserve particular attention as they are protected throughout Europe. Here, we present a case study related to the expansion of an industrial site, part of the megaproject Turin–Lyon high-speed railway, where forest compensations were used to reverse biodiversity loss. The site expansion scheduled for 2020 included mature forests and clearings that used to host a butterfly species and at least 15 bat species protected by the Habitats Directive and other taxa of conservation concern. Forest compensations are usually used to finance tree plantations and forest improvements. In this case study, for the first time, we used them to maintain local biodiversity, which otherwise would have been severely compromised by the site expansion. Indeed, our approach has made it possible to allocate forest compensation funding to restore or improve habitats to favor biodiversity. This approach may be exported to other megaprojects to support local biodiversity.