A student who survived the Parkland high school massacre has accused one of his teachers of locking him and more than a dozen other students in the hallway as the gunman opened fire.

Josh Gallagher, a junior from Coral Springs, Florida, posted a scathing message on social media accusing his math teacher, Jim Gard of Pompano Beach, of being a coward during the February 14 massacre.

Gard defended himself, telling the South Florida Sun-Sentinel that he was simply following the rules and that he didn’t see any students in the hall.

‘I’m a victim of the Marjory Stoneman Douglas shooting,’ Gallagher wrote in a Twitter post on Wednesday.

‘Before the shooting took place I was located in the 700 building which is right next to the freshmen building facing it in my Math class with my Teacher Jim Gard,’ he writes.

Josh Gallagher (seen above on the left with his father), a junior from Coral Springs, Florida, posted a scathing message on social media accusing his math teacher, Jim Gard of Pompano Beach, of being a coward

Mathematics teacher Jim Gard speaks with reporters at Marjory Stoneman Douglas High School on February 23

‘It was around the time of 2:20 when we had a fire alarm go off, everyone in my class was confused because we had one take place previously in the day.’

As the class evacuated for the fire drill, gunshots were heard.

‘At this point we all ducked and shock kicked in for half a second of what is happening,’ he writes.

That’s when Gallagher says he and his classmates sprinted back to their room.

‘As we made it to the door we found out the door was locked,’ he writes.

‘Which then left me and 15 other students in the hallways ducking as the screams of classmates and gunshots took over the noise around me.’

Gallagher writes that he and the others were ‘ducking and in fear for our lives’ a full four minutes.

‘I called my dad [who is a high-ranking officer in the Coral Springs Police Department] up on the phone thinking this could be the last time I speak to him,’ he writes.

‘As I was on the phone with him as he tried to calm me down, a teacher I never seen before opened [sic] the door for me and 14 other classmates to flee danger.

‘When I got into the classroom I told my dad I loved him, he then said it back to me and he hung up because he was a first responder running into the freshmen building.’

‘God bless the teacher who opened [sic] the door to save us from danger…

‘Hours and days after the shooting I came to found out [sic] ... Jim Gard actually ran back into the classroom without turning around and locked his door.

‘He left 75 percent of his students out in the hallway to be slaughtered.

‘How can a man such as him be viewed as a hero in the media?

‘While the shooting was happening and students were locked in the hall he actually called a news station [to] inform them what was going on instead of attempting or even thinking to save kids he left in the hall!’

Gallagher blasted Gard as an ‘opportunist’ and ‘nothing but a coward.’

‘He has re-victimized the students he left out of his class by calling himself a hero,’ he writes.

Gard defended his actions, saying that he had to lock the door as mandated by the rules during a fire drill.

‘I looked back down the hall and no one was around — no one,’ said Gard.

‘You have to close the door. That’s protocol. We have no choice.’

Gard said he and his students huddled in the dark near his desk. That’s when they heard a loud bang.

Gard defended his actions, saying that he had to lock the door as mandated by the rules during a fire drill

‘I told the kids we can’t let anyone in,’ he said.

‘We had no idea if it was a drill or not. By the time I walked over to the door, the banging had stopped.

‘I didn’t hear any yelling. If there were 13 kids outside the door screaming and banging I would have heard them.’

Gard said when he heard helicopters overhead, he understood this was no ordinary fire drill.

‘We hear the choppers overhead,’ Gard said. ‘We get online and see all the news reports.’

Gard said he and the students inside the room began texting the others to make sure they were safe.

‘Fast forward to Sunday, when the parents came back for an open house,’ Gard said.

‘All of a sudden this kid comes over and starts screaming at me. Then his father started screaming at me. This is insane.’

When the Sun-Sentinel asked Gallagher to respond, he wrote: ‘I’m not going to sensationalize this even like my teacher did.

‘I want change to happen when it comes to protocol and the way this situation is handled. No child can feel the way I did.’

Gallagher's claims appeared to be corroborated by another student at Marjory Stoneman Douglas High School.

Gallagher's claims appeared to be corroborated by another student at Marjory Stoneman Douglas High School. The student, Connor Dietrich, tweeted that he was among the kids left in the hallway during those harrowing four minutes

The student, Connor Dietrich, tweeted that he was among the kids left in the hallway during those harrowing four minutes.

'As one of the kids left in the hallway I want people to understand how terrifying and defenseless I personally felt,' he tweeted.

'The person I had to rely on left us to die and that’s not okay.'

Dietrich has been quoted in other media articles about the massacre.

The reaction on social media to Gallagher's post was largely sympathetic to him and critical of Gard.

The reaction on social media to Gallagher's post was largely sympathetic to him and critical of Gard

One person tweeted: 'I say this as a teacher. If your claim is true, that man should be terminated immediately.'

Another tweeted: 'Thank you for sharing your experience. I will share your tweet as I’m sure many others will and your story will not be overlooked. I’m so proud of you for speaking your truth! What your math teacher did was inexcusable!'

Another Twitter user who identified herself as a teacher tweeted: 'This is disturbing.

'As a teacher, I don’t know what I would do under such terrifying circumstances, but I do know that my students are precious to me.

'I have an ethical and moral obligation to protect, but I also have an emotional tie to them that pulls at my motherly instincts.'

Seventeen people – 14 students and three faculty members – were killed in the massacre, which has ignited a fierce debate nationwide about gun policies.

Nikolas Cruz, 19, has been charged with the premeditated murder of 17 students at the Marjory Stoneman Douglas High School, Parkland, Florida on February 14.

Nikolas Cruz, 19, (pictured in court on February 19) has been charged with the premeditated murder of 17 students