LOS ANGELES -- Two men opened fire on a police car patrolling a tough part of Los Angeles but the two officers inside were not injured as one returned fire and a suspect was arrested, authorities said Monday.

The shooting occurred amid heightened tensions over attacks on police elsewhere in the country after grand juries decided against indicting officers in the killings of unarmed black men.

Police officials did not say if they had determined a motive for the Sunday night shooting in South Los Angeles -- an area plagued by gang violence -- but said there were no indications it was linked to other attacks on police in the country.

"It was a complete unprovoked attack," LAPD Deputy Chief Bob Green said initially. "They were just driving on the street and somebody struck out and tried to kill two policemen."

However, Green later said police were also looking into whether the officers might have driven into an ongoing incident and were inadvertently fired at.

"Last night the initial assessment based on the reaction of officers and the adrenaline factor was they were getting ambushed, but you know, things change and it takes a lot to investigate this," Green said.

One man was arrested shortly after the attack. An hours-long search followed for the second man but he remained at large and an investigation was continuing.

The names of the suspect and targeted officers were not released.

The two officers were responding to an unrelated radio call and driving slowly in a neighbourhood when they saw two men on a sidewalk and the flash of a rifle being fired, police said.

The officers stopped their car and one got out and returned fire as the men fled. Police found one suspect, uninjured, a short time later along with a rifle and another weapon.

Police searched the neighbourhood throughout the night for the other suspect, warning nearby residents to stay in their homes. Police stopped the search early Monday after the suspect was not found.

Protesters in California and across the country have rallied for weeks against police killings of unarmed black men in Missouri and New York.

The killing of two New York City officers in their patrol car has departments on edge across the country.

The New York gunman ambushed the officers then killed himself after posting threats online, including references to the fatal shooting of 18-year-old Michael Brown in Ferguson, Missouri, and the chokehold death of Eric Garner in New York City. Both were killed by white officers.