A male suspect hit by gunfire died Thursday night after he “ambushed” a Fremont police officer near a hospital as the officer drove back to the police station, authorities said.

The fatal shooting occurred at 10:49 p.m. on Civic Center Drive, south of Mowry Avenue, according to Fremont police. Three police officers were involved in the shooting, which is still under investigation.

At a Friday morning news conference, Fremont Police Captain Fred Bobbitt said an officer was driving in a marked patrol car southbound on Civic Center Avenue on his way back to the police station when his vehicle was struck by gunfire.

The male suspect emerged from the east side of Civic Center Drive as the officer drove by Washington Hospital’s emergency room driveway, firing a handgun at the patrol car and striking the driver’s side, according to Fremont police. The suspect ran across the road by the time the officer made a U-turn and fired back with his rifle. Two officers on patrol nearby immediately responded to the scene, police said.

“When two additional officers arrived to assist the initial officer, the suspect then, while on the ground, crawled and grabbed his gun, pointed it at the two officers, who then engaged and struck him,” Bobbitt said.

Police said the officers commanded the suspect to show his hands and not reach for the gun before firing at him. The suspect then fell to the ground after being shot, with his arms and hands beneath his torso. Officers detained him and provided medical aid, but he was pronounced dead at 11:07 p.m.

The suspect, who was not identified, possessed a handgun at the time of the shooting, police said.

“It’s going to take us a little while to figure out who he was and why he ambushed our officers,” said Geneva Bosques, a Fremont police spokeswoman.

The Alameda County coroner’s office has not released the identity of the suspect.

No officers were injured during the shooting.

The department plans to make body camera footage from the shooting available within the next seven to 10 days, she said.

Thursday’s shooting was the first police shooting in Fremont this year. The city’s last police shooting was in April 2018, when officers fatally shot 18-year-old Nathaniel Prasad after he opened fire on them.

Gwendolyn Wu is a San Francisco Chronicle staff writer. Email: gwendolyn.wu@sfchronicle.com Twitter: @gwendolynawu