An MTA subway conductor who nearly died in a knife attack on a Bronx platform in April took pity Friday on his violent but gravely ill stabber, agreeing to let him stay out of jail and even ride the trains — but only to travel to cancer treatment.

Otherwise, the stabber, who suffers from a deadly case of leukemia — and who’d ranted to cops, “I stabbed him! So what? Gimme my knife!” — could have been sentenced to as much as 25 years prison for attempted murder.

“It was definitely a tough call on my part,” said victim Denaul Jenkins, 33.

“But he could possibly die in a few months,” he told The Post after court.

“The important thing is that if he is going to be released to medical care and psychiatric care, I hope he does get better,” he added.

“But at the same time, as transit workers, we can’t be punching bags for the public.”

Jenkins was stabbed in his neck and abdomen and nearly lost his spleen when the crazed Rivera, 20, jumped him for no reason at the 149th Street and Grand Concourse station.

The conductor was bleeding profusely but still grabbed hold of Rivera and kept him from fleeing until police got to the station.

Jenkins had hoped that Rivera could somehow be barred from using the MTA ever again. But when he learned that Rivera would sometimes need to travel by train or bus for his ongoing bone-marrow and stem-cell treatments, the conductor had a change of heart.

On Friday, Jenkins signed off on a plea deal whereby Rivera agreed to only hop the train to get to treatment — and only if no other transportation was available.

Rivera also agreed to attend mental-health treatment, keep his record clean for two years and stay away from Jenkins.

Prosecutors also signed off on the deal; Assistant DA Dan DeFillipi noted that Rivera’s cancer treatments may have caused “a psychotic episode which led to the abnormal behavior that precipitated the event.”

Eric Loegel, vice president of the Transport Workers Union, attended the plea-deal hearing, as did more than a dozen of Jenkins’ colleagues.

Loegel put his hand on Jenkins’s shoulder as they left court together, remarking, “This is an honorable man right here.

“He is much more merciful, I think, than many of us would be.”

Jenkins remains out of work, explaining, “I am not fully OK. I just have to let my wounds heal.”