A retired NYPD officer pulled his revolver to subdue a bat-wielding homeless man threatening passengers on a city subway Wednesday.

The incident occurred on the G train in Brooklyn around 7 a.m. when a man wielding a bat threatened David Morales, a retired 28-year NYPD detective who happened to be carrying his revolver, the New York Post reported.

“You’re gonna hit me with a fucking bat?” Morales said as he brandished his snub-nose revolver. “Stay where you’re at. Stay where you’re at.”

Retired NYPD detective helps collar bat-wielding subway maniac https://t.co/kFEYe2RRFB pic.twitter.com/Z9twqNBgX1 — New York Post (@nypost) June 20, 2019

Another subway passenger captured the exchange on a cell phone video. The detective holds his gun by his side while talking to the unruly passenger, who repeatedly yells, “You’re threatening me!”

At the end of the video, the officer informs the man he is under arrest. NYPD Transit posted a tweet supporting Morales’s actions.

His blood still blue, retired NYPD Detective Dave Morales showed calm and restraint when a man threatened subway passengers with a bat- Now an Administration for Children’s Services investigator, Dave’s concern and care for kids carried over to fellow subway riders yesterday pic.twitter.com/pTBGcldWIe — NYPD Transit (@NYPDTransit) June 20, 2019

Police identified the suspect as Brian Baska, a homeless man.

The detective said he is required to carry his firearm as part of the job he now holds with another city agency, according to an interview with CBS2.

Morales said he reverted to his training, and was glad he was there to help with the situation.

“What you don’t see in the video is that he had put the bat behind his back getting ready for a swing. When I took out my revolver, that’s when he decided not to swing,” Morales said.

“He was looking to commit a crime. If it wasn’t me, it would have been someone else,” he added. (RELATED: Man Who Planned To Blow Up New York City Subway Stations Could Be Released Soon)

“This retired NYPD member of the service should be commended for his restraint and his tactics in this incident,” NYPD spokesman Phil Walzak told the New York Post. “He can be seen alerting people outside the train car to move away for their safety, and directing riders on the subway to move away from the perpetrator. He is constantly checking his surroundings while still focusing on the perpetrator, and keeping his weapon pointed downward.”

Police charged Baska with menacing and criminal possession of a weapon.

Follow Whitney Tipton on Twitter

Content created by The Daily Caller News Foundation is available without charge to any eligible news publisher that can provide a large audience. For licensing opportunities of our original content, please contact licensing@dailycallernewsfoundation.org.