  Terzan 5 is a heavily obscured stellar system located in the inner Galaxy. It
has been postulated to be a stellar relic, a Bulge Fossil Fragment witnessing
the complex history of the assembly of the Milky Way bulge. In this paper, we
follow the chemical enrichment of a set of putative progenitors of Terzan 5 to
assess whether the chemical properties of this cluster fit within a formation
scenario in which it is the remnant of a primordial building block of the
bulge. We can explain the metallicity distribution function and the runs of
different element-to-iron abundance ratios as functions of [Fe/H] derived from
optical-infrared spectroscopy of giant stars in Terzan 5, by assuming that the
cluster experienced two major star formation bursts separated by a long
quiescent phase. We further predict that the most metal-rich stars in Terzan 5
are moderately He-enhanced and a large spread of He abundances in the cluster,
Y = 0.26-0.335. We conclude that current observations fit within a formation
scenario in which Terzan 5 originated from a pristine, or slightly
metal-enriched, gas clump about one order of magnitude more massive than its
present-day mass. Losses of gas and stars played a major role in shaping Terzan
5 the way we see it now. The iron content of the youngest stellar population is
better explained if the white dwarfs that give rise to type Ia supernovae (the
main Fe factories) sink towards the cluster center, rather than being stripped
by the strong tidal forces exerted by the Milky Way in the outer regions.
