A teenager pleaded guilty and was sentenced in Hennepin County Juvenile Court this week for his role in a shooting that wounded an on-duty Minneapolis police officer in August.

William Ward Jr., 17, who shot at the officer but did not strike him, was charged with attempted second-degree murder. The plea deal calls for him to receive treatment at the Red Wing juvenile facility and remain on extended probation until he's 21 — with a suspended 13-year adult sentence hanging over his head, court records show.

At Ward's sentencing Wednesday, officer Jacob Spies provided a victim impact statement in front of his colleagues, including Chief Brian O'Hara and Assistant Chief Katie Blackwell, before Judge Mark Kappelhoff.

"I stand with officer Spies and his family as they call for those who were responsible to be held accountable under the law," O'Hara said in a statement to the Star Tribune. "We are confident that justice will be served, and we cannot ever forget the traumatic effect that violence like this has on its victims, their families, and entire neighborhoods."

MPD confirmed that Spies, a seven-year department veteran who was shot in the shoulder, was cleared to return to work full time in early November. The department would not comment on whether it agreed with Ward's plea agreement.

Four people were arrested and three faced charges of attempted second-degree murder or aiding an accomplice in the aftermath of the shooting. Frederick Leon Davis Jr., 19, of Minneapolis is accused of firing at Spies. He remains in custody ahead of his trial, slated for March.

Hennepin County Attorney Mary Moriarty's office petitioned to have Ward, also of Minneapolis, certified as an adult and stand trial in adult court.

But last week, prosecutors and public defenders negotiated a deal. In exchange for Ward admitting to the attempted murder charge, the state agreed to drop its petition and instead designate Ward as extended jurisdiction juvenile (EJJ), according to court records. EJJ is a form of extended probation that allows minors to avoid a lengthy adult prison sentence and remain in the juvenile system if they don't reoffend.

"Given his lack of criminal or delinquency history, probation recommended EJJ in this case and we agreed with that disposition," a statement from the prosecutor's office read. "If he does not succeed, he has 13 years in prison that could be imposed."

The office did not confirm how long Ward is expected to stay at the juvenile facility. It said Ward is required to complete programming at Red Wing before he is released.

According to the criminal complaint:

Just before 8 p.m. Aug. 11, officers observed a white Chevrolet Equinox in the area of a robbery that had just occurred in north Minneapolis. The Chevy initially pulled over but then sped away.

Spies was driving alone in the unmarked vehicle as part of a focused enforcement detail when he saw the Chevy about an hour later and pursued it for about a mile. As he crested a hill, Spies noticed the Chevy parked with its lights off. Suddenly he was hit by a volley of automatic gunfire and felt his arm go numb.

He drove off and a backup officer pulled him from the vehicle and raced him to the hospital. Responding officers later spotted the Chevy and initiated a high-speed chase that continued for 26 blocks until the Chevy crashed into a parked car.

Two suspects, later identified as Davis and Nevaeh Lee Page, 20, fled on foot. Ward "stumbled out of the car with an apparent head injury," while another man— who wasn't charged — remained in the vehicle until he was arrested.

Charges do not list a motive for the shooting, or indicate whether the suspects knew they were targeting law enforcement. In addition to driving an unmarked sedan with tinted windows, Spies was wearing a blue Minneapolis police T-shirt rather than full uniform.

Investigators found two firearms in the car: a fully automatic Glock 19, equipped with a switch, on the front floorboard of Davis' seat, as well as a Polymer 80 9 mm "ghost gun" without serial numbers in the back where Ward was sitting.

Preliminary ballistics evidence suggests the Glock fired 12 shots and the 9 mm fired three.

As part of the plea deal, Ward has a lifetime firearm ban.