NEW YORK — New York Gov. Kathy Hochul endorsed Assemblyman Zohran Mamdani for New York City mayor Sunday in an opinion piece in The New York Times, presenting herself and Mamdani as allies against President Donald Trump.

“New York needs leaders who will put aside differences, stand up and fight back against Mr. Trump,” Hochul wrote, expressing particular concern with the president’s tariff hikes, public assistance program changes, federal funding cuts and threats to take over the city.

Hochul also noted that, “Anyone who accepts his tainted influence or benefits from it is compromised from the start.”

“Mr. Mamdani and I don’t see eye to eye on everything, and I don’t expect us to,” Hochul wrote. “But I also believe that New York State and New York City are at our best when we stand together against those who attempt to tear us apart.”

The governor also repeatedly referenced the need to make New York City more affordable.

Mamdani thanked Hochul on social media.

“I’m grateful for the Governor’s support in unifying our party, her resolve in standing up to Trump, and her focus on making New York affordable,” he said in a post on X. “I look forward to the great work we will accomplish together.”

The stunning success of Mamdani, a 33-year-old self-described democratic socialist, in the race for New York City mayor has exposed divisions within the Democratic Party as it struggles to repair its brand more than half a year into Trump’s presidency. Hochul’s endorsement is the latest sign that Democratic leaders who had been skeptical of Mamdani’s liberal views are beginning to consolidate around him.

Mamdani, who is leading in the polls, has not been endorsed by some prominent Democrats, including Chuck Schumer and Hakeem Jeffries, the minority leaders in the U.S. Senate and House.

In recent weeks, the other candidates in the mayoral race — former Gov. Andrew Cuomo, incumbent Mayor Eric Adams and Republican Curtis Sliwa — have intensified their criticism of Mamdani over his platform and past statements ahead of the city’s general election in November.

Mamdani soundly defeated Cuomo in the Democratic primary. Cuomo has since relaunched his campaign as an independent. Adams, a Democrat, skipped the primary to run as an independent in November. Sliwa ran unopposed in the Republican primary.

The Associated Press contributed to this story.