A man who ambushed a police officer sitting in his marked car, firing more than a dozen shots at point-blank range, said he was acting in the name of Islam, US authorities said.
Both the officer and suspect were wounded during the barrage of gunfire in Philadelphia.
The suspect, 30-year-old Edward Archer, also pledged allegiance to the Islamic State group when he was questioned after his arrest in the shooting, police said.
Police Commissioner Richard Ross described the attack on Officer Jesse Hartnett, captured on a police surveillance camera, as an attempted assassination.
"He just came out of nowhere and started firing on him," he said. "He just started firing with one aim and one aim only, to kill him."
Mr Ross said Archer told police he believed the department defends laws that are contrary to Islam.
Police said there was no indication anyone else was involved. but Mr Ross added: "It stands to reason there is more unknown than known."
Though Archer "clearly gave us a motive," Mr Ross said it is now up to police to see what the evidence shows.
Federal agents joined local police in searching two Philadelphia area properties associated with Archer, including the home where his mother lives.
Captain James Clark, head of the homicide unit, said Archer told investigators: "I follow Allah. I pledge my allegiance to the Islamic State and that's why I did what I did."
Archer's mother, Valerie Holliday, told The Philadelphia Inquirer he has been hearing voices recently and that family asked him to get help. She also said her son felt targeted by police, and described him as devout Muslim.
Jacob Bender, the executive director of the Philadelphia chapter of the Council on American-Islamic Relations, said he contacted about five inner-city mosques and found no-one who knew of Archer.
He said at this point, the motive still appears to be conjecture.
"I think the important point is not to lay the blame for this on the entire Islamic community," he said.
The gunman fired at least 13 shots toward Mr Hartnett and eventually got up next to the car and reached through the driver's-side window, investigators said.
Despite being seriously wounded, the officer got out of his car, chased the suspect and returned fire, wounding his attacker in the buttocks.
Other officers chased Archer and apprehended him.
Mr Hartnett, 33, was shot three times in the arm and will require numerous operations, but was in a stable condition.
Archer was treated and released into police custody.