He was out for NYPD blood.

The fare beater who allegedly shot a rookie cop after getting yanked off a city bus admitted he wanted to kill a police officer, a source told The Post.

“Cops are the biggest gang and I carry a gun for my own protection,” Rashaun Robinson, 28, said at the 71st Precinct, according to a second source. “I fired in self-defense.”

Officer James Li, 26, who is just a few weeks out of the police academy, and his partner caught Robinson and another man boarding a city bus through the back door without paying on Wednesday afternoon.

When they pulled the men off the bus to arrest them, Robinson allegedly opened fire with a .45 caliber Smith & Wesson, hitting Li in both legs with three shots.

Cops never had a chance to cuff and frisk him. He ran off, but was collared nearby.

Li was treated at the scene by a pair of off-duty EMTs — Khadijah Hall and Shaun Alexander — who were leaving a nearby White Castle when the shots were fired.

“My friend Shaun said ‘I can’t believe this! You got any gloves?’ It was like cops and robbers!” Hall said Thursday at EMS Station 58 in Canarsie.

Alexander said Li was calm but feared he had been more seriously wounded.

“When we got there he was all concerned that he was shot all over. I checked, said, ‘No, you’re OK, you’re gonna be all right,’” Alexander said.

Robinson, who said nothing when he was led from the 71st Precinct Thursday night for his criminal court arraignment, is a fugitive from Lebanon, Penn., wanted on a 2012 drug warrant.

Authorities there admitted to The Post they didn’t have enough manpower to hunt him down for allegedly taking part in a crack sale to an undercover officer.

The Lebanon County Sheriff’s Department said Thursday it has more than 2,500 open warrants, and just 26 employees — including civilians — to enforce them all.

Chief Deputy Sheriff Deborah Miller said her department entered Robinson’s warrant into state and national law-enforcement databases so he would be held if stopped elsewhere.

Lebanon County DA Dave Arnold said, “I certainly hope and pray for the health of” NYPD cop James Li, who Robinson allegedly shot on Wednesday.

“I know we’ve got a whole wall full of cabinets with warrants here in our office and we certainly do our best to apprehend who we can, but unfortunately we don’t get everybody,” Arnold added.

Additional reporting by Gillian Kleiman and Lorena Mongelli