YAKIMA, Wash. — A 16-year-old boy accused of gunning down a rival gang member near the Yakima Transit Center last year pleaded guilty Friday to second-degree murder.

Daniel Perez Jr. faces from 16 to 24½ years in prison for his guilty plea, which includes a five-year firearm enhancement, in the Oct. 23, 2012, slaying of Octavio Rangel. Sentencing is set for Nov. 26.

Perez was 15 at the time of the slaying. In June a judge approved a request by Yakima County prosecutors to try him as an adult.

Perez was caught near the scene of the shooting, which occurred at dusk on a sidewalk near the transit center at Chestnut Street and Fourth Avenue. Rangel, 26, was shot five times, including twice in the head.

Also arrested in connection with the slaying was Irving D. Alvarez, a 24-year-old gang member known on the street as “Lil Lazy.” He remains in custody pending trial on a charge of second-degree murder as an accessory.

Deputy prosecutor Gary Hintze said he agreed to dismiss a charge of first-degree premeditated murder against Perez because of the difficulty, at trial, in proving premeditation.

Per the terms of his plea deal, Perez faces between 194 to 294 months in prison under state sentencing guidelines. Both sides are free to argue the range. Hintze said he plans to recommend the maximum of 24½ years.

Prosecutors said the shooting was precipitated by a dispute between Rangel and Alvarez over a debt. They said Perez intervened and shot Rangel with a .45-caliber pistol. Rangel did not have a criminal record locally, but he did have a record in Grant County that included a 2006 conviction for first-degree robbery.

At the time of the slaying, Perez had a growing record as a juvenile that included convictions for attempted residential burglary, first-degree criminal trespassing and third-degree malicious mischief.

In addition, he was the younger brother of Leonardo Perez, a La Raza Norteño whose slaying in 2009 remains unsolved.

During a hearing this summer in juvenile court, witnesses described Perez’s parents as hard workers who did everything they could to provide him with a safe environment. They twice filed At-Risk Youth petitions with juvenile authorities in hopes of getting him under control.

County juvenile officials compiled reports of Perez refusing to go to school, punching holes in the walls of his parents’ home and how he once pushed his mother in an attempt to steal the family’s TV.

There was also a case in Bend, Ore., in which he was accused of punching another boy in the face with brass knuckles, when he was 11. That case was dropped because of his age and the fact that he lived in Washington.

In a family of 10 children, only Daniel and Leonardo were involved in gangs and crime. After Leonardo was killed, Daniel joined his gang, according to court documents and family testimony.