The teenage gunman responsible for the Florida high school massacre that left 17 dead had nearly free reign during the early stages of the carnage because cops and administrators failed to take key steps that could have saved lives, it was reported Friday.

An investigation by the South Florida Sun-Sentinel included horrifying pictures of 19-year-old Nikolas Cruz roaming the first-floor hallways of Parkland’s Majory Stoneman Douglas High School as he shot his former classmates, seemingly at will, in the February bloodbath.

The paper said school administrators and law enforcement officials could have headed off the shooting in its earliest minutes and saved lives — but failed to do so.

“Security monitor Andrew Medina, an unarmed baseball coach, is riding in a golf cart and unlocking gates 20 minutes before dismissal. He sees Cruz walk through one of those unguarded gates with a rifle bag,” the paper reported.

“He recognizes Cruz as ‘Crazy Boy,’ the former student that he and his colleagues had predicted most likely to shoot up the school. He radios another campus monitor/coach, but he does not pursue Cruz and does not call a Code Red to lock down the school.”

Medina never should have been on the job in the first place, according to the report.

“School investigators had recommended he be fired for sexually harassing students, but district administrators overruled them,” the paper wrote.

Its investigative team found that Medina was the first of three school employees who failed to call for a lockdown “after learning a gunman is on campus.”

Instead, Medina alerted at least one other staffer — David Taylor, who spotted the gunman lumbering down the hall with his rifle bag in hand.

Security camera footage showed that Taylor turned the other way, later telling investigators he attempted to use the stairs at the other end of the hallway to cut Cruz off on the second floor.

On the videotapes obtained by the paper, Cruz is seen walking into a stairwell where just seconds later an unsuspecting freshman, Chris McKenna, entered to see the 19-year-old killer loading his gun.

“You’d better get out of here,” Cruz said. “Things are gonna start getting messy.”

McKenna ran and told football coach Aaron Feis that there was someone in the school with a gun. The newspaper found there was no evidence that Feis used his radio to call for a “code red” lockdown — the second missed chance.

With his weapon out, Cruz left the stairwell and fired his first shots — killing three freshmen in a first-floor hallway.

Taylor heard the shots and raced up to the second floor, where he ducked into a janitor’s closet, the report said.

He had a radio, but didn’t call for a lockdown — a third missed chance to limit the carnage, the Sun-Sentinel found.

Another 14 students and staff would die in the hour-long rampage — many after a fire alarm sent them scrambling into hallways and right into the gunman’s path.