MIAMI – A newly surfaced video shows a Miami police officer accidentally used his stun gun on a fellow officer during a chaotic arrest in January.

Kenia Fallat, a spokeswoman for the Miami Police Department, said the officers were arresting Riboberto Castillo, a 26-year-old homeless man with a lengthy criminal record, on Jan. 4. Castillo, who Fallat said was high on crack cocaine at the time, resisted, causing the officer to accidentally stun his partner with his Taser.

In the video, the stunned officer falls to the ground, but he quickly gets to his feet and continues to help his partner with the arrest. The officers also used the stun gun on Castillo, but he continued to resist. Castillo can be heard moaning and screaming, "Stop it" and "You're doing this for no reason."

Fallat said the officer was not hurt in the incident and Castillo was eventually taken into custody on drug possession and resisting arrest charges. Despite a prolonged struggle with the officers which in he was punched several times, Castillo was not injured, Fallat said.

According to Castillo's arrest report, the incident began when the officers observed Castillo handing a crack pipe to another man -- Lazaro Perez -- near Southwest 12th Avenue and Southwest Third Street in the city's Little Havana neighborhood.

Perez, 57, fled as officers arrested Castillo, but he was arrested on drug and weapons charges the next day.