An emotionally disturbed man set off panic inside a subway train when he assaulted a woman, prompting riders to jump in and subdue him while someone pulled the emergency brake, cell phone video shows.

The man began screaming in a violent, hate-filled tirade that began on the subway platform at 34th Street and continued on a Brooklyn-bound D train Thursday evening, according to witness Jessica Valencia.

He yelled racial slurs at random straphangers and "he was pushing people, almost pushed people off the platform," said Valencia.

"He started screaming, saying everyone should die," she said. "We were all slaves, his slaves."

When a woman on the train challenged the man's rant, he hit the woman in the face, video taken by Valencia shows.

She hit him back before other straphangers jumped in, but one panicked rider tugged on the emergency brake, trapping riders with the apparently disturbed man underground.

The conductor ushered riders out of the car, isolating the man in a car by himself until the train reached the DeKalb station, where police took him into custody.

Former NYPD detective Bo Dietl, who's now a private security expert, says riders did the right thing by working together to subdue the unarmed man, but says they should have avoided pulling the emergency brake.

"It's not a good thing. There's no one there to help you" when the train is stuck underground, he said.

The man was taken to Woodhull Hospital for a psychological evaluation. Charges were pending, according to police.