A US soldier is being hailed as a hero after he severed his own leg to save his crewmates during a freak accident, officials said.

While deployed to Poland last year, Army Spc. Ezra Maes, 21, was sleeping in a tank as part of an overnight training exercise when he was jolted awake by the machine rolling downhill, according to the Department of Defense.

“I called out to the driver, ‘Step on the brakes!’ ” Maes said. “But he shouted back that it wasn’t him.”

The crew initiated emergency brake procedures, but nothing would stop the tank as it sped down the hill at nearly 90 miles per hour.

“We realized there was nothing else we could do and just held on,” Maes said.

The tank ultimately crashed into an embankment, sending Maes flying across the machinery and leading his leg to get caught in a gear.

Fearing for the rest of the crew, Maes was determined to free his own leg.

“I pushed and pulled at my leg as hard as I could to get loose and felt a sharp tear,” Maes said. “I thought I had dislodged my leg, but when I moved away, my leg was completely gone.”

Despite bleeding heavily, Maes rushed back to the tank to grab a tourniquet from the medical kit.

“All I could think about was no one knows we’re down here,” he said. “Either I step up or we all die.”

After performing life-saving measures on himself, Maes called out to another soldier, Sgt. Aechere Crump, whom he had throw him his phone.

He unlocked his phone and sent a text to a friend in order to get the crew help, he said.

Maes was rushed to a local hospital before he was airlifted to Landstuhl Regional Medical Center in Germany. He has since returned to the US for treatment at the Brooke Army Medical Center Warrior Transition Battalion in Houston, Texas.

Doctors were unable to save his leg but he said he’s grateful that he survived the terrifying episode.

“I feel super lucky,” he said. “My crew all does. So many things could have gone wrong. Besides my leg, we all walked away pretty much unscathed.”