Students have shared the terrified messages they sent their loved ones as a gunman rampaged through their school killing 17 and leaving almost two dozen injured.

Barricading themselves in their classrooms, the Marjory Douglas Stoneman High School students sent what they believed could be their final messages to friends and family.

'If I don't make it I love you and appreciate everything you did for me,' student Sarah Crescitelli, 15, wrote to her parents while hiding out for two hours in a school bathroom, in texts obtained by the Miami Herald.

'Don't talk that way,' one parent responded. 'The cops are all over.'

'If I don't make it I love you and appreciate everything you did for me,' student Sarah Crescitelli, 15

Sarah Crescitelli (pictured) spent two hours hiding in a school bathroom before she was rescued by police

Sarah and her parents had an emotional reunion after the gunman was arrested at 4pm on Wednesday and the lockdown on the school was finally lifted.

A 14-year-old student texted his frantic parents who offered to come and pick him up after news of the active shooter situation at the school.

'Is it all over? Mom wants to come get you now/ Is that even possible?' his dad asked.

But the brave teen told his parents to stay away.

'You could get hurt,' he texted them.

'Ok stay stay buddy love you,' his dad replied. 'Be safe man, stay hidden or play dead if there is an active shooter.'

The chilling messages show a dad urging his son to 'make a blockage with the tables' or 'go in a closet' to stay safe, while the student replied he could hear 'screaming near by'

Another message shows a student and their loved one sharing notes on the location of the shooter

Traumatized parents were seen waiting for news after they rushed to school following reports of the mass shooting at Marjory Stoneman Douglas High School in Parkland

The 14-year-old has since been reunited with his family.

One terrified student, named Hannah, began texting her sister Kaitlin to ask her for help.

'Kaitlin there is a shooter on campus. I am not joking. Call 911 please. Send them to Douglas,' she messaged. Her sister replied, asking if it was a joke.

'Kaitlin I am not joking they just shot through the walls someone my class is injured.'

'I love you so much,' her sister responded.

The trapped student said she was 'so scared' before telling her sister how much she loved her and asking her to tell their parents that 'I love them so much.'

Kaitlin later tweeted the correspondence, confirming that her sister was home safe.

One terrified student, named Hannah, began texting her sister Kaitlin to ask her for help

A mom got off her flight to find a terrifying list of messages from her child who was at the school during the shooting

Seventeen people were killed in one of the worst school mass shootings in history. Around 20 were injured when former student Nikolas Cruz, 19, allegedly opened fire with his AR-15 assault rifle.

The troubled loner, and white supremacist, sparked terror at the Parkland school, Florida, when the first gunshots rang out at 2.25pm.

Students fled for safety or huddled inside classrooms as the gunman prowled the halls.

James Harrison, a sophomore at the high school, texted his stepfather, 'I love you,' and said he was 'really scared.'

He also texted his stepfather Joe, telling him to call 911 but not to ring him because he was hiding from the shooter.

A junior, who asked not to be named, told BuzzFeed News that he texted his family because he believed that 'this could be the last thing I ever say to them.'

Students left the school on Wednesday with their arms on each other's shoulders

An injured female was transported from the school on a stretcher by first responders on Wednesday afternoon. 17 were left dead and 15 were injured in the attack

The chilling messages show his dad urging his son to 'make a blockage with the tables' or 'go in a closet' to stay safe, while the student replied he could hear 'screaming near by.'

'I love you babes,' his dad wrote, 'U will be ok, just pray.'

'I love you too,' his son replied.

'I just couldn't believe it because there were so many shots that I heard and I was so scared and I was so anxious because I didn't know what was going on,' Harrison told Fox News after the shooting.

'I saw everybody else in my class was texting their family members,' he said, 'so I just ended up picking up my phone just doing the exact same thing and trying to contact.'

Beth Feingold told the Associated Press that her daughter, Brittani, text her saying 'We're on code red', adding 'Mom, I'm so scared.'

She and her daughter were later reunited.

James Harrison, a sophomore at the high school, texted his stepfather, 'I love you,' and said he was 'really scared'

One message showed that a student's father was in tears after learning the news

Another student begged her dad to come and get her.

'We're in a real code red dad, get me ASAP it's not a drill,' read one message that an unidentified student's father received.

'I hear gunshots. We just got a code-red notification so get me ASAP. There are gunshots in our school. Hell, someone died. Come now.'

Len Murray told the AP that his 17-year-old son, who is a junior at the school, sent him a text saying: 'Mom and Dad, there have been shots fired on campus at school. There are police sirens outside. I'm in the auditorium and the doors are locked,' according to the AP.

Moments later the teenager texted, 'I'm fine.'

Murray was among the scores of parents rushing to the school to see if their children were ok.

Gunman Nikolas Cruz, 19, is in custody. He is a former student

When they arrived, they found the school on lockdown and the surrounding roads has been closed off.

Eventually, SWAT teams tracked down the suspected gunman, who is believed to have escaped the building by blending in with the other students, and he was arrested.

He is charged with 17 counts of murder and other charges.

Students Jaime Guttenberg, 14, Nicholas Dworet, a high school senior, Martin Duque, 14, Meadow Pollack, 18, Cara Loughran, Alaina Petty, 14, Joaquin Oliver, 17, Luke Hoyer, 15, Alyssa Alhadeff, 15, Gina Montalto, 14, Carmen Schentrup and Peter Wang, 15, Alex Schachter, and Helena Ramsey were all killed in the shooting.

Track coach Aaron Feis, 37, geography teacher Scott Beigel, 35, and athletic director Chris Hixon, 49, were also among the casualties. Fifteen people were injured.