NEW YORK — At least 40 were arrested in Times Square Thursday while protesting the police-related shootings of two black men this week, police said.

The protesters on Thursday chanted "The people united, never be divided" and "Hands up don't shoot." Police scrambled to keep up with the crowd as the group left the park and marched up Fifth Avenue.

It was reported that about 500 people staged a "sit down" at West 42nd Street and Seventh Avenue.

A second group gathered in Times Square where many were arrested by the NYPD. Another group headed to Harlem, and continued protesting into early Friday morning.

On Wednesday, a Minnesota officer fatally shot Philando Castile while he was in a car with a woman and a child in a St. Paul suburb. The aftermath of the shooting was purportedly livestreamed in a widely shared Facebook video.

A day earlier, Alton Sterling was shot in Louisiana after being pinned to the pavement by two white officers. That, too, was captured on a cellphone video.

Protests Around the Country

In Minneapolis, a crowd gathered outside the governor's mansion in the morning and grew throughout the day.

They raised their voices against police brutality and the death of Philando Castile, who was shot to death Wednesday during a traffic stop in nearby Falcon Heights.

"If we are silent we are compliant," protester Bridget Mendoza Smith said. "Black men are being murdered by the hand of police officers in our city."

Valerie Castile, mother of Philando Castile, told a crowd gathered outside J.J. Hill Montessori Magnet School in St. Paul, where Castile worked, that somebody "needed to police the police."

"It was my son today but it could be yours tomorrow," she said. "This has to cease. This has to stop, right now."

She also urged an economic boycott to bring attention to the killings of black men. "The only thing they know is money," she said.

In Baton Rouge, Louisiana, protesters gathered outside the convenience store where Alton Sterling died on Tuesday while police arrested him, less than 24 hours before Castile's death.

Tokens, flowers and signs piled up in a makeshift memorial. Protesters chanted "Hands up, don't shoot," the line made famous in the Michael Brown shooting in Ferguson, Missouri.

A prayer vigil was held at a church. Louisiana Gov. John Bel Edwards spoke and a minister urged anybody who carried a weapon to take it out of the sanctuary and store it in their car.

As has become the horrible norm, both killings were captured on video and posted online, helping the outrage spread across the country.

The shooting of Castile was live-streamed by his fiance, who calmly narrated the action and showed viewers the dying man groaning and bleeding in the front seat.

"Oh God, please don't tell me my boyfriend is dead," she says.

Protests were also held in Dallas and Austin, Texas, as well as other large cities.

CNN and the Associated Press contributed to this report.