They chanted “Not our president” and “New York hates Trump” and carried signs that said, among other things, “Dump Trump.” Restaurant workers in their uniforms briefly left their posts to cheer on the demonstrators.

The demonstrations forced streets to be closed, snarled traffic and drew a large police presence. They started in separate waves from Union Square and Columbus Circle and snaked their way through Midtown.

Loaded dump trucks lined Fifth Avenue for two blocks outside Trump Tower as a form of protection.

Emanuel Perez, 25, of the Bronx, who works at a restaurant in Manhattan and grew up in Guerrero, Mexico, was among the many Latinos in the crowd.

“I came here because people came out to protest the racism that he’s promoting,” he said in Spanish, referring to Mr. Trump. “I’m not scared for myself personally. What I’m worried about is how many children are going to be separated from their families. It will not be just one. It will be thousands of families.”

Protesters with umbrellas beat a piñata of Mr. Trump, which quickly lost a leg, outside the building.

The Police Department said on Wednesday night that 15 protesters had been arrested.

Bianca Rivera, 25, of East Harlem, described Mr. Trump’s election as something that was “not supposed to happen.”

“We’re living in a country that’s supposed to be united, a melting pot,” she said. “It’s exposing all these underground racists and sexists.”