The man suspected of shooting an off-duty Chicago cop earlier this week on the Far South Side is a paroled carjacker who allegedly confessed to the shooting, but claimed it was accidental, authorities said Wednesday.

Samuel Harviley, 24, was ordered held without bond Wednesday on charges of attempted murder and armed robbery in the early Monday shooting of the officer, who was parking his car near his home in Washington Heights after studying for a detectives’ exam.

Harviley and an accomplice were armed when they sneaked up on the officer at about 2:20 a.m., authorities said. Harviley snatched the keys from the car and threw them on the driveway, prosecutors said at the bond hearing.

The accomplice allegedly told the 49-year-old officer to get out of the car and lie still on the ground. The accomplice then stole the officer’s wallet and cell phone while Harviley trained his gun on him, prosecutors said.

The officer was worried they would find out he was a cop and shoot him. On the seat was a study guide for a Chicago Police Department detective exam he planned to take. He also thought they would find his service weapon when they frisked him.

Harviley’s partner allegedly said “shoot him” if the officer moved. Harviley then shot the officer, who managed to fire his service weapon at his assailants and strike Harviley in the arm, authorities said.

Harviley went to Little Company of Mary Hospital in Evergreen Park, where he said he was the victim of a drive-by shooting in another part of Chicago, said Anthony Guglielmi, chief spokesman for the police department.

Gresham District officers checked out the story, decided it was fishy and contacted detectives who determined Harviley was the suspect in the officer’s shooting, Guglielmi said. The officer picked out Harviley in a photo array, prosecutors said.

Police are now searching for a female getaway driver and Harviley’s alleged accomplice, Guglielmi said.

Harviley was on parole for a carjacking. In 2012, Harviley, who has a tattoo that says “Live Strong Die Hard,” was sentenced to nine years in state prison for aggravated vehicular hijacking. He received credit for about a year and a half that he spent in the Cook County Jail and was paroled on Dec. 31.

Interim Police Supt. John Escalante said Harviley’s case is a powerful demonstration that state law is too easy on violent criminals.

“The allegations against Mr. Harviley and his two criminal associates are quite frankly reprehensible,” Escalante said in a statement.

“Time and time again, CPD officers risk their lives to hold repeated guns offenders accountable and we will stop at nothing to continue that promise, but more needs to happen to change the culture of violence and increase accountability.”

It was the second time in a week that a felon had shot a Chicago Police officer. On March 14, 29-year-old Lamar Harris wounded three on-duty officers during a brief gun battle on the West Side before he was fatally shot by the police.

The officers were conducting a narcotics investigation and followed Harris into a courtyard where he shot at them, and at least one officer returned fire, authorities said. One officer was hit in the back, one in the foot and one in his bulletproof vest.

Harris, an admitted gang member, had 43 arrests on his rap sheet. In 2010, officers heard a call about a man with a gun and stopped Harris as a suspect. Harris allegedly struck an officer in the head and reached for his waistband, dropping a gun, police said. In 2012, he was sentenced to four years in prison in the case.

The carjacking for which Harviley was convicted happened in 2011. He and another man approached a victim who parked his Chevrolet Malibu outside a friend’s home when Harviley and three other men walked up. Harviley pulled out a black revolver. The victim gave the robbers his car keys and wallet. The robbers warned the victim not to look at their faces or they would shoot him.

The victim reported the carjacking to the police, who spotted the car and chased Harviley on foot. He tripped over a tree branch and dropped the gun, court records show. Harviley was carrying the victim’s cellphone and was later identified by the victim in a lineup, police said.

Guglielmi pointed out that 26 of the 35 people shot in the the city last weekend were on a Chicago Police list of people who are at a high risk of becoming crime victims because of their criminal records and interactions with other people involved in violent crime. One man had been shot two other times since 2012 and had 42 arrests on his record, including a 2010 gun conviction.

“This just further illustrates the individuals that are driving the violence,” he said.