His re-election campaign has repeatedly described his likely Republican opponent, Nicole Malliotakis, a state assemblywoman who represents parts of Staten Island and Brooklyn, as a strong supporter of Mr. Trump, who was broadly rejected by New York City voters in the presidential election.

Here in Minneapolis, Ms. Hodges, a City Council member before becoming mayor in 2014, describes herself as a progressive. She helped enact an ordinance mandating paid sick leave for workers. But she was seen by many as too slow to embrace a $15 minimum wage and as too heavy-handed in her response to a protest encampment that formed after the fatal police shooting of an unarmed black man, Jamar Clark, in 2015.

“Her main focus, from my perspective, was on ending the occupation because it was making the city look bad,” said Nekima Levy-Pounds, a leader of the protests and now a candidate for mayor. “There was a lot of coldness, iciness.”

The city government’s reaction — and Ms. Hodges’s role in it — infuriated people on all sides. Activists were aghast that police officers had donned riot gear and used pepper spray. Police union leaders were angered that officers had not been permitted to clear the streets and arrest protesters who camped out for 18 days. The Justice Department later criticized her coordination with police officials.

But in recent months, as she fights for a second term, Ms. Hodges has tried to change the subject.

She donned a pink hat and attended the Women’s March in St. Paul. She pledged to stand in the way of Mr. Trump’s crackdown on sanctuary cities. And after giving her State of the City speech at the mosque this spring, she cheerfully deflected a Fox News reporter’s question about whether she would have given a similar speech at a church.