A man died after suffering a heart attack at Kennedy Airport after two teams of first responders failed to reach him — because their electronic ID cards couldn’t open secure doors at the newly renovated Delta terminal, The Post has learned.

Precious minutes were lost due to the tragic snafu, which unfolded early Saturday when Gunseye Adekunle, 50, of New Jersey, collapsed in the $1.4 billion Terminal 4 while he was preparing to board an Arik Air flight to Nigeria, sources said.

A call went out for help, but what happened next was a massive mix-up.

“You had all the assets needed to keep this guy alive, but they never really had the chance to help him,” a law-enforcement source said.

A Port Authority police emergency operator got the call at about 6:30 a.m. and was told Adekunle was “unresponsive” but breathing.

One minute later, a PAPD ambulance known as Medical One was dispatched — but the crew reported being unable to enter the terminal from the street two minutes afterward because an officer’s security card wasn’t working.

“Access denied at elevator,” a radio transmission noted.

The trouble delayed the Medical One team for two vital minutes, but then they were able to get into the building by another route and get to Adekunle.

The Medical One rescuers are only EMTs, however, and the plan was for an FDNY crew of better-equipped and better-trained paramedics to arrive and take over.

But that second rescue squad also ran into frustrating issues with security doors. At about 7:10, the Fire Department responders were denied entry when the security system refused to recognize an ID access card used by a PA cop escorting them. The delay robbed the dying man of more precious seconds.

“Seconds are critical when responding to a cardiac event,” a source familiar with the incident said, “and unfortunately, unnecessary obstacles take away those critical seconds and possibly a patient’s fighting chance.”

A source said the cop used his card twice at one entry point and again at a second, but was unable to lead the FDNY team inside.

The decision was eventually made to bring Adekunle down from the terminal to the FDNY ambulance.

He was placed in that vehicle for transport to Jamaica Hospital, where he was declared dead.

A PA dispatcher later noted that there was a “delay in patient contact due to elevator/SIDA card denied access in T-4.”

A spokesman for the PA said that the department was looking into the incident.

“The safety of our public is always of paramount importance,” he said in a statement.

A Delta spokeswoman said the company was not responsible.