One California Highway Patrol officer was killed and two were injured on Monday in a gun battle in Riverside, California, a department spokesman said.

The suspect was also killed. Police said the man was armed with a rifle, but his motive was unknown.

Police officers returned fire when the suspect shot at them during a traffic stop, said Riverside Police Department spokesman Ryan Railsback.

California Governor Gavin Newsom on Twitter identified the officer who was killed as Andre Moye.

Gavin Newsom Tweet

The incident took place at about 5.35 p.m. local time, and shots were heard as police pulled a fellow officer out of the line of fire, according to NBC Los Angeles.

Twitter: Just In: Large police presence at Box Springs Blvd. off 215 Freeway. CHP advises public to avoid area after possible shots fired. An officer's vehicle has a shattered windshield with bullet holes.

Aerial footage showed that bullet holes had shattered the windshield of an officer's vehicle, according to NBC Los Angeles. Emergency personnel were seen giving CPR to one person and there were traces of blood on the hood of a white truck, the network reported.

Riverside is located about 35 miles east of Los Angeles. The incident took place at Eastridge Avenue near the 215 Freeway.

Recent mass shootings have reignited the debate over gun violence in the United States. On Aug. 3, a lone gunman opened fire at a Walmart store in El Paso, killing 22 people. Within 24 hours, another mass shooting occurred in Dayton, Ohio, killing at least 9 people.

—CNBC's Ted Kemp contributed to this report.