A Philadelphia man pleaded guilty Thursday to fatally shooting 2-year-old Nikolette Rivera in 2019 by firing a rifle into a Kensington rowhouse in a botched attempt to target her father — a killing that prompted public outcry as it capped a gruesome week of violence against children.

Tayvon Thomas, 26, said little as he entered his plea to third-degree murder, attempted murder, and related charges during a proceeding held by Zoom. Common Pleas Court Judge Lillian Ransom will sentence him later this summer, and he faces decades behind bars.

Thomas also pleaded guilty to stabbing three jail guards with a shank while in custody last year, and he will be sentenced for those crimes at the same time.

In the shooting of Nikolette, Thomas and his accused coconspirator, Freddie Perez, 31 — whose case remains pending — approached her family’s home, on the 3300 block of Water Street, on Oct. 20, 2019, seeking to target her father in an ongoing feud over drugs and previous violence, said Assistant District Attorney Jeff Hojnowski.

Thomas fired five shots through the front of the house even though the girl’s father, Nikolai Rivera, was not home. A man who had just arrived to clean the carpets was struck in the stomach. Nikolette, who was in her mother’s arms, was struck in the head.

Moments before the shooting, Thomas had fired 10 shots from the rifle at a passing SUV a few blocks away on the 400 block of Clearfield Street. That crime was captured on surveillance video, and authorities said it was part of the same plot to target rival drug dealers in the neighborhood.

Thomas, who had a long history of arrests, confessed to both shootings to detectives days later, Hojnowski said.

Nikolette’s mother, Joan Ortiz, testified at Thomas’ preliminary hearing in December 2019 and described how she and her daughter were knocked to the ground by the shots, and how she knew the child was dead before first responders arrived.

Ortiz watched Thursday’s proceedings by Zoom, occasionally dabbing her eyes to wipe away tears.

The shooting of Nikolette was the second time a child had been struck by gunfire that weekend — both allegedly with the same assault rifle.

In the first crime, an 11-month old boy was shot four times when someone fired at the car he was in, driven by his stepmother. The gunman then allegedly sold the weapon to Thomas and Perez, who used it during their shooting spree 24 hours later.

Thomas is due back in court for a sentencing hearing in August.