MADRID — Her conservative rivals demonized her as a heavy spender, a former Communist certain to bust the budget in no time. Yet four years later, Mayor Manuela Carmena of Madrid is the favorite as she faces voters for a second time on Sunday, having cut the city’s multibillion-euro debt by nearly half.

If anything, it is Ms. Carmena’s leftist backers who have criticized her for bowing to Madrid’s powerful business lobby.

Ms. Carmena, 75, shocked the Spanish political establishment in 2015 by winning the mayoralty with a far-left campaign promising, among other things, to right the city’s finances and root out corruption after more than two decades of rule by the conservative Popular Party.

She no doubt benefited from an upturn in Spain’s economy, after a long recession that ended in 2013. And Madrid was subject to spending limits imposed by the national government, to prevent the kind of Pharaonic building projects undertaken during Spain’s construction boom.