Chaotic footage of a New York City subway brawl that ended with a man shot with his own gun appears to show a female companion of the alleged shooter stab the other man before the gunfire rang out.

The violence unfolded aboard a crowded A train rumbling toward Brooklyn's Hoyt-Schermerhorn Streets station around 5 p.m. Thursday, according to authorities.

Video widely shared on social media - which is graphic and contains profanity - shows a 36-year-old man described by police as the "aggressor" yelling at a fellow rider, 32. Neither of the men was immediately identified by name.

 

"I'll beat you up," he said in the video.

"You think you gonna beat up cops? You think you people gonna beat up cops?" he went on to ask, in an apparent reference to a January fight in Times Square between NYPD officers and a group of migrants.

A woman on the train can be heard saying, apparently to the 32-year-old, "He thinks you're a migrant. He thinks you're an immigrant."

The aggressor then got in the face of the seated man and continued his tirade, the video shows.

"F-k you, f-k your kind, f-k your race," he said.

As the tensions escalated, the 32-year-old stood up, and fellow commuters cleared out as he squared up against the 36-year-old, the video shows.

"There's babies on here!" one woman yelled, in a vain attempt to stop the fight.

As the two men threw punches at each other, a woman came up behind the 36-year-old and repeatedly struck him in the lower back, the video shows.

Blood then began to pool on the 36-year-old's back, visible through his white shirt.

"You stabbed me?" the aggressor asked in apparent disbelief.

A bystander in a reflective vest temporarily separated the men, only for the bloodied 36-year-old to continue yelling and reach into what appeared to be a jacket he'd previously flung onto a subway seat, the video shows.

The motion is followed by the sound of a gun cocking, then din as commuters rushed to put even more distance between themselves and the fight.

Multiple gunshots then rang out, though the video did not capture images of the shooting, as the person recording it fled into the station along with several others.

Police said Thursday that the 32-year-old managed to wrest the gun away from the 36-year-old and fired multiple rounds, leaving him in critical condition. The 32-year-old was taken into police custody at the station.

Criminal charges had not been announced as of early Friday.