VERMELHOS, Portugal — Portugal has scrambled to find solutions to wildfires that have ravaged the country in recent years. It has tested high-tech tools like drones and used satellites and aircraft to fight the fires. It has grappled with long-term policy changes to improve land management that could prevent them.

And then there is the goat.

Part of Portugal’s problem, as in other southern European countries, is that inland villages have shed their populations. The absence of shepherds, goatherds and farmers has left forest lands overgrown, allowing fires to spread and burn faster. Steep slopes are out of reach for a tractor and are very costly to tend by hand, difficult in any case for an aging population.

A simple, low-cost solution, Portuguese officials now hope, may lie with the humble goat, which feeds on the underbrush that fuels fires, if only enough goatherds and shepherds can be found and supported in a way of life that is disappearing.

Leonel Martins Pereira, 49, is his village’s last. Increasingly, he may also be Portugal’s first line of defense against wildfires.