An MTA worker miraculously survived being electrocuted by a third rail at the Yankee Stadium subway station Friday — and even walked up emergency stairs to the street afterward.

The lucky-to-be-alive track supervisor, 52, was overseeing work in the southbound D train tunnel at the 161st Street station around 3 a.m. when he was walking on the tracks and he came into contact with its potentially deadly, live third rail, an MTA source told The Post.

Yet not only did the man survive, he was able to climb up an emergency-exit stairway on his own and exit a hatch at Ogden and Jerome avenues, where an ambulance picked him up and took him to Harlem Hospital, coworkers said.

Emergency first-responders were at the scene and by his side at the time.

Transit workers at the station said the unidentified supervisor only suffered minor burns to his leg.

But colleagues visiting their injured pal at the hospital Friday afternoon appeared upset after seeing him.

“This is not a good time,” one man told The Post.

The MTA source said the man suffered a “serious” injury.

MTA President Andy Byford addressed media after visiting the man in the hospital and said a full investigation was under way.

“We need to make sure that we get to the root cause of what happened here,” Byford said.

He calling the incident an “unusual situation,” noting the employees are trained to work with the power on.

Just last month, another person died after coming into contact with the third rail in the New York subway system.

The 56-year-old man, who was possibly homeless, was electrocuted at the Delancey Street station on the Lower East Side on July 25 as he wandered through the tunnels.

Trains are powered by the electricity that runs through the tracks’ third rail.

Additional reporting by Olivia Bensimon and Ebony Bowden