"FBI star Derek Hedlund nearly died after being cut by a crab.

Hedlund told Page Six that he was helping a pal move a Jet Ski in Red Bank, N.J., in July when the crustacean clawed at his foot, leaving a tiny cut -- and it turned out that the water he was wading in was infected with the “flesh-eating bacteria” Vibrio.

Hedlund told the outlet that his foot swelled up alarmingly, and at one stage a doctor said to him, “You see this line on your leg? That is the [vibriosis] spreading up your leg. You can literally see it.”

Medical staff even told the actor that if it reached a certain point on his leg, they’d have to amputate it to save his life.

JARED LETO RECALLS 'NEARLY' DYING WHILE ROCK CLIMBING

Derek Hedlund recalled the time he nearly died after being cut by a crab.

Derek Hedlund recalled the time he nearly died after being cut by a crab. (IMDB)

To make matters worse, Hedlund told Page Six he got the call to return for the second season of “FBI” while he was in the hospital, and -- not wanting to risk losing the gig -- promised producers that he’d be on set in just a few days. He says he discharged himself “against medical advice” to attend a wardrobe fitting, and showed up to the shoot on crutches a couple of days after leaving the hospital.

CLICK HERE TO GET THE FOX NEWS APP

To his horror, the script had him chasing “terrorists” through Central Park. He said that while the shoot was excruciating, “I did what I needed to do, and I’m still alive.”

This article originally appeared in The New York Post.