One of two men charged in the Aug. 18, 2012, robbery and slaying of Philadelphia Police Officer Moses Walker pleaded guilty Thursday in a deal that lets him escape life in prison if he cooperates in the prosecution of the alleged shooter.

Chancier McFarland, 21, of North Philadelphia, pleaded guilty to third-degree murder in the predawn shooting of Walker, 40, as he walked to a bus stop after finishing his shift as a turnkey in the 22d District.

Walker, a 19-year veteran of the force, was fatally shot about 6 a.m. Surveillance video showed him being confronted by two armed men.

McFarland also pleaded guilty to participating in two strong-arm robberies of corner grocery stores on Feb. 28, 2011.

Seated next to defense attorney Jonathan J. Sobel, McFarland said nothing during the hour-long hearing but one-word answers as Common Pleas Court Judge Glenn B. Bronson asked if he understood the constitutional rights he was giving up.

Bronson told McFarland that he would be sentenced to 20 to 40 years in prison if he fulfills his promise to cooperate in the prosecution of Rafael Jones, 25. Bronson said McFarland, who is also facing prison time in a federal carjacking case, would be allowed to serve his state sentence in a federal prison.

Bronson deferred sentencing until after Jones' trial, a death-penalty case set to begin Dec. 1.

The slaying put Pennsylvania probation policies under scrutiny when it was learned Jones had been released by state probation officers three days earlier - after testing positive for marijuana use and failing to find a proper place to live under house arrest.

Assistant District Attorney Jude Conroy said McFarland has given two statements admitting his role in and describing Moses' shooting. The first was after he surrendered to the FBI in Mobile, Ala., on Aug. 26, 2012, and the second last month.