SACRAMENTO (CBS13) — A Sacramento Police officer is recovering after investigators say he was ambushed outside a hospital.

Police have arrested two men in the case.

Juan Gomez, 21, is accused of ambushing the officer and brutally beating him for no other reason than the officer’s profession.

Sacramento police say it happened early Monday morning in a parking lot at Kaiser South medical center. They say Gomez knocked on the officer’s patrol car window and lured the officer out.

“The man had told the officer that there was someone in the area with a gun. He immediately and violently attacked the officer,” said Sacramento Police spokesman Doug Morse.

The officer, taken by surprise, was knocked to the ground.

“The attack continued when that individual actually jumped on that officer and continued to strike him in the face,” Morse said.

While the attack was happening, police say Jamaral Lee, 35, recorded the attack and encouraged Gomez. Eventually security guards and bystanders noticed what was happening, and helped stop the attack. Both Gomez and Lee were placed under arrest while the officer rushed into the hospital.

“It’s a very, very difficult thing to protect against,” said former Sacramento County Sheriff John McGinness.

He says it’s more than troubling to hear of the attack. He says over the past couple of years, police officers have been under attack. He recalled the recent ambush killing of a Houston-area sheriff’s deputy shot point-blank while fueling his car and the NYPD officers killed last year while sitting in their patrol car.

“We’re likely to see an era, at least for a while, in which law enforcement will have to approach overall general contact with the public differently,” he said.

Pastor Les Simmons, an advocate for the local Black Lives Matter movement, says attacks like this set back progress.

“I could say to this individual and individuals that may think that what this young man did was justifiable that that doesn’t represent our community; it doesn’t represent change,” he said.

It’s a change he says the community has been working toward.

“There’s been a real effort both by the community and by law enforcement and the city to really have a conversation that moves our community into a better place,” he said.

Gomez faces a number of felony charges for allegedly beating that officer.

Lee faces a felony charge of advocacy of killing a peace officer.

Morse says officers have been briefed on the incident, but no changes are planned in response to the attack.