(Reuters) - A former Northern California police officer pleaded no contest Monday to assault and vandalism for beating a woman with a baseball bat while off duty, officials said.

Prosecutors said Gregory Thompson, 53, wore a mask in the attack, which took place outside of a home owned by a relative.

The officer, who retired last week from the Walnut Creek Police Department near San Francisco, faces up to five years and eight months in prison in the attack, Contra Costa County deputy district attorney Barry Grove said.

The incident took place early on the morning of Aug. 16, when Thompson was surveying a family member's home in the blue-collar suburb of Richmond that was vacant but had recently been broken into, Richmond police said.

At around 2:00 a.m., a woman's car ran out of gas in front of the home. She left her vehicle to seek help when a masked man approached and began beating her with a baseball bat, police said.

“Maybe she looked suspicious or it was a mistaken identity,” Richmond Police Lieutenant Andre Hill said. “We don’t know what his mindset was, but we do know this woman had nothing to do with the house.”

Police received reports of a screaming woman being chased by a man with a baseball bat. After arriving on the scene, witnesses directed officers to Thompson, who was hiding in his car. Police found two guns, a baseball bat and a mask in the vehicle.

Thompson told Richmond police he was a law enforcement officer and was taken into custody without incident, Hill said.

The woman suffered non life-threatening injuries. Another woman was injured trying to intervene in the attack. Police have been unable to locate her.

After the attack Thompson was placed on paid administrative leave, Captain Mark Perlite of the Walnut Creek Police Department said. Thompson retired last Friday.

At the arraignment Monday, Thompson pleaded no contest to assault with force likely to cause great bodily injury and felony vandalism. He also faces an enhanced sentence for carrying a firearm during the attack.

His sentencing hearing is set for Oct. 10.

(Editing by Sharon Bernstein and Eric Walsh)