(CNN) A 30-year-old man who allegedly ambushed and shot a Philadelphia police officer sitting in his patrol car confessed he did it in the name of the Islamic State, presumably referring to the terrorist group ISIS, officials said Friday.

Officer Jesse Hartnett, 33, was hit three times in the left arm on Thursday night and suffered "some very serious injuries that will require multiple surgeries," police Commissioner Richard Ross told reporters.

Despite being seriously injured and bleeding heavily, the veteran officer got out of his patrol car and shot the assailant in the buttocks, Ross said. The gunman was apprehended by other officers, Ross said.

"He was trying to assassinate this police officer," Ross told reporters.

The alleged assailant was armed with a 9mm Glock 17 that was reported stolen from the home of a police officer in 2013.

"It is one of the things that you regret the most, when an officer's gun is stolen that it is used against one of your own," Ross said

Capt. James Clark, commander of the homicide unit, told CNN the suspect said to investigators: "I follow Allah. I pledge my allegiance to the Islamic State and that's why I did what I did."

Clark said: "He just kept on echoing those sentiments and he wouldn't give us anything more than that."

'I'm bleeding heavily'

Philadelphia police shooter suspect Edward Archer

The alleged gunman was identified as Edward Archer, of Yeadon, a Philadelphia suburb, police said.

Archer allegedly confessed to carrying out what Ross described as a "cowardly act" in the name of Islam.

"According to him, he believed that the police defend laws that are contrary to the teachings of the Quran," the police commissioner said.

Still Images released by police from surveillance video show the gunman -- wearing an ankle-length, white garment -- on a crosswalk taking aim and firing at the patrol car at close range. In one photo, the suspect is standing next to the car with his arm through the lowered driver's side window, close enough to be shooting at point-blank range.

Ross told reporters the video, which is not being released, was "absolutely one of the scariest things I've ever seen."

Hartnett shouted desperately into his police radio moments after the gunman unloaded at least 11 shots, police said.

"Shots fired! ... I'm bleeding heavily!" Hartnett shouts in a recording of his radio call for backup.

"I'm bleeding. Get us another unit out here!"

Harnett's elbow was shattered, his brachial artery -- a major blood vessel in the upper arm -- was hit, and blood vessels and nerves in his arm damaged, according to a Philadelphia law enforcement official.

Still, the officer demonstrated his "valor and courage" by stepping out of his car as the gunman retreated and opening fire, according to Ross. The shooting happened about 11:30 p.m. in west Philadelphia.

The Philadelphia Inquirer reports that this image is from surveillance video of Thursday night's shooting.

"I'm absolutely amazed that Officer Hartnett is here with us today," the police commissioner said.

'Nothing to do with being a Muslim'

The shooting in Philadelphia is the fourth attack believed to have been inspired by ISIS on American soil, including the December 2015 shootings that left 14 dead in San Bernardino, California, the shootings outside a Prophet Mohammed cartoon contest in a Dallas suburb in May 2015, and a hatchet assault on four police officers in New York in October 2014.

Officials said they did not know whether the latest attack was part of a broader conspiracy or whether Archer had contact with terrorists.

Archer traveled to Saudi Arabia in 2011 and Egypt in 2012, FBI Special Agent Eric Ruona said. Ruona could not comment on whether investigators think Archer interacted with any terrorist groups during these trips.

Mayor Jim Kenney said the shooting had nothing to do with Islam.

"It is abhorrent," he said. "It does not represent the religion in any shape or form or any of the teachings. This is a criminal with a stolen gun who tried to kill one of our officers, and it has nothing to do with being a Muslim or following the Islamic faith."

Imam Asim Abdur-Rashid, head of a mosque one block away from an address associated with Archer, condemned the attack at a news conference. He said he did not know whether the alleged shooter attended his mosque.

A gun sits by a marker after Thursday night's shooting in west Philadelphia.

Arrest history

Gov. Tom Wolf said he is "thankful that Officer Hartnett is alive and not facing life-threatening injuries after being ambushed."

"We wish him and his family the best during his recovery. This alleged intentional act of violence against an officer seeking to help a fellow citizen is horrifying and has no place in Pennsylvania," he said.

Archer was arrested in 2012 after a domestic dispute and later pleaded guilty to assault and carrying a gun without a license, court records show. He was out on probation Thursday and was scheduled to be sentenced Monday after he was found guilty on charges of careless driving, forgery and driving with a suspended or revoked license in a 2014 case.

In the 2012 domestic dispute, Archer "pulled a small black and silver semiautomatic handgun from his waist and pointed it towards the complainant's stomach while grabbing the complainant's shirt," according to the affidavit for probable cause.