Police were ambushed by four gunmen during a traffic stop, authorities said.

A San Bernardino police officer was wounded Friday night in a shootout with two suspects following what began as a routine traffic stop, officials said.

The suspects opened fire at two officers after being stopped for a traffic violation just after 9 p.m. near the intersection of Base Line Street and Sierra Way in San Bernardino, according to police.

The officers returned fire, shooting both suspects in the legs, police said. One officer sustained a gunshot wound to the leg.

The two suspects and the wounded officer were taken to Loma Linda University Medical Center, police said.

The officer's injuries were not life-threatening and he was released, said Sgt. Brett Birnbaum of the San Bernardino Police Department.

Two suspects -- Eric Newsom, 22, of Los Angeles and Keijuan Mayfield, 22, of Redlands -- remain in police custody. Newsom was arrested on suspicion of attempted murder.

Two other passengers in the suspects' car fled the scene on foot. Police are asking anyone with information about the case to contact Det. John Munoz at (909) 384-5630 or Sgt. Gary Robertson at (909) 841-5361.

ALSO:

Amanda Bynes' mental-health hold extended

San Diego Mayor Bob Filner's June trip to Paris questioned

L.A. girl kept in metal box on pot farm for sex, authorities say

Twitter: @MattHjourno

matt.hamilton@latimes.com