A man was beaten and stabbed on a Manhattan subway train after refusing to give a group of would-be robbers his money, police said.

The man, identified by sources as Roberto Hernandez, 39, was riding the northbound D train in Lower Manhattan at about 1:45 a.m. Saturday when a group of five people approached him and demanded cash, cops said.

When he refused, two of the men began punching him in the face, sources said.

But Hernandez kept resisting, and a third man, 17, called for a woman in the group to hand him a knife.

He stabbed Hernandez in the head and torso, police said.

When the train reached the Grand Street stop, the attackers jumped off and fled the station after taking nothing.

Hernandez was taken to Bellevue Hospital for injuries to the head and chest.