Wilbert Castillo was driving his SUV on South Broad Street when he found himself sharing the road with a group of ATVs that slowed down in front of him, and he accidentally hit a dirt bike.

He got out to apologize to the man whose bike he struck and was violently attacked, he testified Friday at a preliminary hearing in the assault case against the dirt bike rider, Gregory Stevens, 27, of Tacony, who stands accused of attacking him.

Castillo, 25, said Stevens punched him and hurled cinder blocks through the windows of the SUV, injuring him and his 13-year-old brother. Two other riders in the swarm of ATVs and dirt bikes threw trash at the vehicle, he said.

The attack was captured on video by a bystander — and quickly went viral. Castillo didn’t know it at the time, but the video — which was played in court Friday — showed Stevens walking toward the SUV with a handgun, but pausing when someone yelled for him to stop.

The violence was jarring, but the swarm of ATVs Castillo encountered are an all-too-common — and illegal — occurrence on city streets. Motorists and residents have long complained that they are menacing, noisy, and a public safety threat.

In court Friday, Castillo described how Stevens hurled a cinder block through the windshield of his vehicle that March 9 evening after he got back into the SUV and locked the doors. He said it landed on the dashboard on the passenger’s side where his brother was sitting. A second cinder block hit Castillo in the back of the neck, and the third hit his left forearm, he said.

Although he has recovered from his physical injuries, Castillo said, “Sometimes, I feel unsafe going out. I feel more anxious than I normally would.”

His SUV suffered $12,760 in damage and was deemed a “total loss.”

Municipal Court Judge David Conroy held Stevens for trial on aggravated assault, illegal gun possession, and related offenses in the attack.

Gwen Callan, Stevens’ public defender, declined comment after the hearing.

Stevens is in federal custody in an unrelated case after being charged last month with robbery and gun offenses in the shooting of a pharmacist in February.