Now comes the hard part.
Gliding to his second landslide victory, Bill de Blasio was re-elected on Tuesday as the mayor of New York City, overwhelming his Republican challenger, Nicole Malliotakis, and a handful of independent candidates in what he declared a persuasive affirmation of his progressive agenda.
Mr. de Blasio, the first Democratic mayor to be re-elected in a generation, since Edward I. Koch captured his third term in 1985, now has four years to further his goal of reshaping the city in his progressive mold.
“It’s a good night for progressives,” Mr. de Blasio said at a victory party at the Brooklyn Museum, with his wife, Chirlane McCray, and his son, Dante, at his side. “For the first time in 32 years, a Democratic mayor was re-elected in New York City. But let’s promise each other: This is the beginning of a new era of progressive Democratic leadership in New York City for years and years to come.”
Yet Mr. de Blasio’s ability to deliver on his agenda may have far more to do with the winds blowing out of Washington and Albany than with circumstances in the five boroughs.
Federal budget cuts — threatened by President Trump and the Republican-led Congress, especially to social programs, health care and public housing — could cause serious problems and exacerbate social ills, forcing Mr. de Blasio to do financial triage. That could potentially drain money from signature programs, like his promise to accelerate and expand a push to build and preserve affordable housing.
And Mr. de Blasio, 56, remains hampered by his inability to forge a working relationship with Gov. Andrew M. Cuomo, a fellow Democrat; many of the mayor’s plans require Albany’s approval, and the mayor has had few willing partners in the Capitol.
He has said that he would crusade in Albany to make the city’s arcane property tax system fairer across neighborhoods. He said that he would appeal to Albany to improve the state’s voting system to increase participation by making it easier to register to vote and to vote early.
He wants money from Albany to make free schooling available to all 3-year-olds. And he wants the state to approve a tax on wealthy New Yorkers to pay for subway improvements.
Mr. de Blasio is counting on his decisive victory to propel those changes. He received 66 percent of the vote, with more than 97 percent of electronic ballot scanners counted.
Ms. Malliotakis, a state assemblywoman from Staten Island, received more than 27 percent of the vote.
Also on Tuesday, Democratic incumbents breezed in the two other citywide races: Public Advocate Letitia James and Comptroller Scott M. Stringer both dispatched poorly financed Republican opponents.
The Manhattan district attorney, Cyrus R. Vance Jr., was also re-elected. He ran unopposed for a third term, but faced a late-emerging write-in campaign after revelations fueled by criticism that he received contributions from defense lawyers representing high-powered clients. In a rebuke to Mr. Vance, 9 percent of voters submitted write-in votes.
Mr. de Blasio’s victory over Ms. Malliotakis was all but assured since March, when federal and state prosecutors ended their investigations into his fund-raising practices and decided not to bring charges. At that point, serious Democratic challengers who had been considering running against Mr. de Blasio opted to stay on the sidelines.
Mr. de Blasio maintained a low-key, play-it-safe campaign, promising to continue the work of his first term to address what he has called the “crisis of affordability.”
He benefited from a strong economy, centering his re-election message on the core accomplishments of his first term — free prekindergarten, investments in affordable housing and low crime — and on his pledge to further his administration’s efforts on early childhood education and housing.
He withstood the sort of last-minute twists and events that could have made an incumbent vulnerable in a different, more closely fought campaign: a former donor testifying in a federal trial that he made contributions in exchange for access to City Hall; a deadly terrorist attack near the World Trade Center days before the vote.
And he benefited from national politics, holding himself up as the city’s bulwark against Mr. Trump, who was roundly rejected by New York City voters in 2016. Mr. de Blasio rarely skipped a chance to point out that Ms. Malliotakis voted for Mr. Trump last November.
Mr. de Blasio called out Mr. Trump Tuesday night. He cheered Democratic victories for governor in key races in Virginia and New Jersey, and added, “Tonight, New York City sent a message to the White House as well.”
He also sounded a note of urgency: “We’ve got to become a fairer city and we’ve got to do it soon, we’ve got to do it fast,” he said. “You saw some important changes in the last four years, but you ain’t seen nothing yet.”
Sal Albanese, who lost to Mr. de Blasio in the Democratic primary and ran in the general election on the Reform Party line, received about 2 percent of votes.
Bo Dietl, a retired police detective who ran as an independent on his own “Dump the Mayor” line, received only about 1 percent, despite having appeared in two televised debates with Mr. de Blasio and Ms. Malliotakis and spending more than $1 million. He received fewer votes than the Green Party candidate, Akeem Browder, and was slightly trailing Michael Tolkin, the independent candidate.
In eschewing broad new proposals, Mr. de Blasio focused his campaign on get-out-the-vote efforts, after only about 14 percent of registered Democratic voters turned out for the New York City primaryin September.
But two weeks before the election, Mr. de Blasio was battered by embarrassing court testimony from a real estate investor who had once been one of the mayor’s most generous political contributors. The man, Jona S. Rechnitz, testifying in the federal corruption trial of a labor leader, talked about trading campaign money for favors and meetings with city officials.
Mr. de Blasio dismissed the testimony as the lies of a felon — Mr. Rechnitz pleaded guilty to a conspiracy count relating to bribery and influence buying — and he seemed to skate past it.
Still, the testimony reminded voters of the state and federal investigations into the mayor’s campaign finance practices that hobbled his administration throughout 2016 and into the first part of this year.
In the end, the campaign could not escape the paradox of the mayor’s personality: The “tale of two cities” of his campaign four years earlier had become a tale of two ways of seeing the mayor — a man who had made good on many of his promises and yet elicited little enthusiasm.
The race was violently punctuated a week before the election when a man drove a rented pickup truck down the Hudson River Park bike lane, killing eight people and injuring a dozen, in what Mr. de Blasio quickly characterized as an act of terrorism. The carnage echoed the terrorist attacks on the World Trade Center in 2001, which occurred on the day of the mayoral primary that year, and helped create the conditions for Mr. de Blasio’s predecessor, Michael R. Bloomberg, to be elected mayor.
But Mr. de Blasio’s reassuring response to the tragedy provided no opening for his rivals to criticize his leadership under crisis.
Ms. Malliotakis, 36, was not well known when she announced in April that she would seek the Republican nomination. Even after months of running, in what was her first citywide race, polls showed that most voters in the city — where Democrats outnumber Republicans among registered voters by more than six to one — did not know enough about her to form an opinion. She struggled to get voters’ attention and to articulate a strong positive case for her candidacy, aside from criticism of Mr. de Blasio.
“I entered this race with eyes wide open, knowing that the odds were stacked against me,” Ms. Malliotakis said after the race had been declared. “We may not have won this race, but we have made our voices heard.”
In 2013, Mr. de Blasio received 795,679 votes, 72 percent of the ballots cast. On Tuesday night it appeared likely that he might not reach the same vote threshold. With 97 percent of scanners counted, Mr. de Blasio had about 706,000 votes.