MADRID — A town hall employee, Ana Garrido held one of the most secure jobs in Spain for two decades. But after she tried to expose corruption behind how her town awarded public contracts, her life descended into what she described as “my seven-year Calvary.”

That path took her from being assailed by her office bosses and colleagues in Boadilla del Monte, on the outskirts of Madrid, to depression and sick leave, unemployment, and even death threats.

She now sells handmade bracelets to make a living, and relies on crowdfunding to help cover her legal expenses, which have reached 20,000 euros, or about $22,600. She has sold most of her clothes and furniture and rents out her home to pay the mortgage. Instead, she lives as a squatter in an abandoned apartment with paint peeling from the walls.

It is only now, as Spain prepares for a rerun of national elections in June, and the issue of corruption moves up the political agenda, that Ms. Garrido is getting some belated recognition for undertaking one of Spain’s riskier endeavors: being a whistle-blower.