The shooting was reported around 5:35 p.m.
Riverside police say a CHP officer conducted a traffic stop of a suspect in a GMC pickup truck and then decided to impound the vehicle.
As he was calling for a tow truck and filling out paperwork, the suspect entered the truck, retrieved a rifle and began firing at the officer, police say.
VIDEO: Eyewitness cellphone footage shows gunman clad in black firing rifle at CHP officers
The officer was able to call for help and three additional CHP officers came to the scene, along with three deputies from the Riverside Sheriff's Department and one Riverside police officer.
They continued the gun battle with the suspect. Two additional CHP officers were injured and the suspect was killed at the scene.
"It was a long and horrific gun battle," said Riverside Police Chief Sergio Diaz. "And it resulted in a very extensive crime scene."
The original officer who conducted the traffic stop was transported to a hospital in Moreno Valley and was pronounced dead.
Family members later identified the deceased officer as Andre Moye, Jr. They said he is 33 years old and married, with no children. He had been with the CHP for about four years, family members said.
"I am devastated by the tragedy that unfolded earlier in Riverside," CHP Commissioner Warren Stanley wrote on Twitter. "Tonight, I mourn the loss of one of our own, CHP Officer Andre Moye, who was killed during a shootout following a traffic stop. Prayers go out to all, including the responding officers injured in the shooting."
One of the CHP officers who responded later to the scene had major injuries and was considered in critical condition. The third officer suffered minor injuries.
Two civilians also suffered minor injuries, believed to be a result of shrapnel or debris and not gunfire.
Family members of the suspected gunman identified him as Aaron Luther, a 49-year-old father of two from Beaumont. His father told Eyewitness News that Aaron was an ex-con who had served time in prison for attempted murder, but was also a married father who was trying to get his life together.
At least two CHP vehicles had visible gunshot damage in the rear windshields at the scene.