A man is in custody for stabbing another man on a C train Saturday morning, according to the city police department.

It happened on a southbound C train around 5:56 a.m., officials said.

Police said a 39-year-old man attempted to rob another passenger, but he fought off the 39-year-old.

Then, that alleged attacker walked up to a 61-year-old passenger and stabbed him in the stomach, according to investigators.

The victim reported the stabbing to a train conductor, who radioed the police.

Officials said officers were waiting when the train pulled into the 59th Street-Columbus Circle station and arrested the alleged attacker.

Police said the victim was taken to a local hospital and is expected to survive.