Scrappy straphangers showed a rampaging mugger who was boss Saturday morning in Manhattan, overpowering a violent ex-con who allegedly stabbed a stranger three times in the gut for refusing to give him money.

It was just after 6 a.m. when Jamel Purnell, 39, decided to turn the southbound C train in Harlem into his own personal ATM machine, flashing a knife and demanding cash from sleepy-eyed riders, police said.

“I was half-asleep and then I see a man with a knife sitting next to me,” said Ricardo Zacarias (inset), 28, a restaurant delivery man. “He turned to me and put his finger over his lips, saying, ‘Shhhh . . . Give me your money.’ ”

Zacarias forked over $6, telling him, “I don’t have any more money,” and Purnell snatched his cellphone too, he recalled.

“I didn’t know what to do but run — so I got up and ran to the other end, where I saw two other [riders]. The man with the knife was following me.”

Purnell next targeted 61-year-old doorman Nicolas Direnzo — who was determined to keep his possessions, which enraged Purnell, police sources said.

“The man with the knife stabbed the old guy three times,” Zacarias recalled, speaking in Spanish through a translator from his Harlem apartment. “It was so much blood.”

“Someone just jumped onto our C train stabbing people,” one witness tweeted in the thick of the morning mayhem. “Woke up to people fleeing towards me from other car train, one man covered in blood.”

But Zacarias and fellow riders wouldn’t let Direnzo fight his battle alone.

“I went back to help the old man,” said Zacarias. “I started to punch and kick the man with the knife from behind — I did whatever I could.”

“Someone had a metal rod and started hitting the man,” Zacarias remembered.

The brave band bolted to another subway car, searching for the conductor — the knifeman stumbling after them.

“The conductor called the police, and said he was shutting the doors so the man with the knife couldn’t come into our car.” Zacarias said.

Then came the long ride to the next stop, as the C train was running express from 125th Street in Harlem to 59th Street at Columbus Circle because of weekend rail work.

“By the time we got to 59th Street, the police were already there,” he said.

Direnzo was taken to Mount Sinai St. Luke’s Hospital and was in stable condition late Saturday.

Neighbors were hardly surprised he refused to go down without a fight.

“Knowing Nick, he would have probably been like, ‘No, get the f–k out of my face’ or something,” said Edward Rodriguez, 29, Direnzo’s neighbor in Morningside Heights. “He [won’t] back down.”

Purnell was treated for his head wound, and charged with robbery, assault, criminal possession of a weapon and menacing.

He has a criminal record dating back to 1995 for robbery, grand larceny, assault and trespass — more than 15 arrests, according to law-enforcement sources.

Additional reporting by Stephanie Pagones, Amanda Woods and Laura Italiano