NEW YORK — Mayor Bill de Blasio cruised to re-election on Tuesday, fending off token opposition to win a second term as the leader of the nation’s largest city.
De Blasio, a Democrat originally from Cambridge, easily defeated Republican state lawmaker Nicole Malliotakis, of Staten Island, and several third-party candidates.
Speaking to supporters at an election night party at the Brooklyn Museum, de Blasio pledged to make New York the ‘‘fairest city in America,’’ promising to increase investments in pre-kindergarten and affordable housing, to put body cameras on all police officers and to fight for more money to fix the subway system.
‘‘We’ve got to become a fairer city. We’ve got to do it soon, and we’ve got to do it fast,’’ he said. ‘‘You’ve seen some important changes in the last four years, but you ain’t seen nothing yet.’’
First elected four years ago, de Blasio emerged as a national leader in progressive politics. But his administration often found itself bogged down in feuds with Gov. Andrew Cuomo, a fellow Democrat, and investigations into campaign donations and pay-to-play politics.
De Blasio is the first Democrat to win re-election as New York mayor since Ed Koch, 32 years ago even though Democrats outnumber Republicans in the city by a 6-1 ratio. His toughest opponent on Tuesday, Malliotakis, had called him ineffective.
‘‘We may not have won the race, but we have made our voices heard,’’ Malliotakis told her supporters. ‘‘If we continue to fight for what we believe in, we can change the course of this city.’’
Third-party candidates in the race included independent Bo Dietl, a former detective.
The 56-year-old mayor has vowed that in his second term he will further expand pre-kindergarten to 3-year-olds and increase investments in affordable housing. He also has promised to continue to speak out for the city’s immigrant and minority communities and be a vocal critic of President Trump.
Reminding his supporters of the upcoming anniversary of Trump’s election, he noted Tuesday’s Democratic gubernatorial wins in New Jersey and Virginia and said: ‘‘America got a little fairer tonight. America got a little bluer tonight. Let’s cheer so they can hear you in New Jersey. Let’s cheer so they can hear you in Virginia.’’
De Blasio said New York City had sent a message to the Republican president.
‘‘You can’t take on New York values and win, Mr. President,’’ he said. ‘‘If you turn against the values of your hometown, your hometown will fight back. And so we have some fights ahead. We will fight, and we will win.’’