That has left Ms. Cruz to play the role of Puerto Rico’s chief critic of the recovery effort.

Censuring Trump certainly jibes with Ms. Cruz’s liberal worldview, but in some ways the mayor can seem as complex and contradictory as the neither-fish-nor-fowl United States commonwealth she calls home.

She is a product of both the island and the mainland, a former star in the blue-chip world of corporate America who is beloved in the poorest barrios of the Puerto Rican capital. She is also an unapologetic supporter of Oscar López Rivera, the Puerto Rican militant associated with a group that carried out a deadly campaign of bombings in New York and other cities in the 1970s and 1980s.

Ms. Cruz, according to a biography on the Puerto Rico Chamber of Commerce website, was an honor student and track-and-field star on the island who went on to receive degrees from Boston University and Carnegie Mellon University in Pittsburgh. She later worked as a human resources director for companies including Colgate-Palmolive, Banco Popular and Scotiabank, as well as the Treasury Department.

She returned to the island in 1992, working as an adviser to a previous San Juan mayor, and was elected to the Puerto Rico House of Representatives in 2008.

She was hardly a well-known figure when she ran for mayor in 2012 against a 12-year incumbent, Jorge Santini, who misjudged the threat and seemed to belittle her by calling her “esa señora,” or that woman. He also characterized her as a Venezuelan-style socialist. Ms. Cruz, meanwhile, stitched together a coalition of students; lesbian, gay, bisexual and transgender groups; and people simply fed up with the status quo, and won. She was re-elected handily in 2016 against a lackluster opponent.

Ms. Cruz is a member of the Popular Democratic Party, which supports maintaining the island’s commonwealth status, rather than statehood. While it is in the minority in both state houses, it includes centrist and center-right members. But Ms. Cruz is firmly ensconced in the party’s small left wing. She allowed for the unionization of San Juan government health workers, and this year she supported a strike led by university students who opposed strict austerity measures after the island, staggering under $74 billion in debt, was forced to declare a form of bankruptcy.

In June, Ms. Cruz explained her opposition to statehood to a reporter from The Guardian. “You don’t fight injustice by asking to become part of the system that committed the injustice against you in the first place,” she told the paper. “That’s like a freed slave striving to become a slave owner.”