Three men are being hailed as heroes after they stepped up to help a California police officer who came under attack while trying to arrest a suspect during the weekend.

The Los Angeles County Sheriff's Department said the incident happened Sunday in Whittier around 3 p.m., when the 23-year-old officer was responding to a call of a homeless man creating a disturbance at a convenience store.

In surveillance video, the deputy can be seen moving in to arrest the man, who is acting erratically, when he starts throwing punches and the deputy loses his balance, falling to the ground.

OHIO DOCTOR ACCUSED OF MURDERING 25 PATIENTS IS SET TO FACE HEARING

In the seconds that followed, the homeless man attempted to grab the deputy's gun from the holster.

The deputy yelled and that caught the attention of Brian Whitney, who told FOX 11 he reacted immediately.

"I heard the officer yell 'Get your hand off my gun,' and as soon as I seen that I went down and ripped the homeless guy's hands of the officer's gun," Whitney said Tuesday.

RETIRED NYPD LIEUTENANT ON 'PANTALEO EFFECT': I'VE NEVER SEEN OFFICER MORALE THIS LOW

Two other men got involved, including one who could be seen sliding the officer's weapon away from the homeless attacker. The group was eventually able to subdue the suspect until additional officers arrived and arrested the man, who was charged with assault.

Whitney said the officer personally thanked him afterward for helping out.

"I told him I wasn't even thinking," he told FOX11. "The only thing I was thinking about was your safety."

CLICK HERE FOR THE FOX NEWS APP

Authorities praised the actions of the three men, saying their efforts helped save the life of the officer.

“He was having a hard time with that guy, and without the help of the good Samaritans, I’m concerned about that,” Capt. Jim Tatreau, of the LACSD told CBS LA. “We’ve had some very good citizens here in La Mirada, Whittier, and Norwalk. And it just reinforces your belief in being all together.”