“Females between the ages of 18 and 21 pose a relatively slight risk of perpetrating a school shooting… or, for that matter, a violent crime of any kind,” says the lawsuit.

The bill’s passage by a Republican-controlled legislature in a state where the NRA wields considerable influence is seen as a testament to an impassioned pro-gun control campaign launched by young survivors of the shooting and parents of the victims.

Governor Scott signed the bill surrounded by Parkland students and families.

“Today should serve as an example to the entire country that government can and must move fast,” he said.

Media playback is unsupported on your device

Media captionStudents have been lobbying for greater gun control

A former student with a history of mental health issues is accused of killing 14 students and three staff members at Marjory Stoneman Douglas High School on 14 February in the second-deadliest US school shooting ever.

The Florida bill is also controversial because it allows school staff to be specially trained to carry guns as campus “guardians”.

However, local sheriffs and individual school districts may opt out and most classroom teachers will be excluded from the scheme.

Six other states – Wyoming, South Dakota, Tennessee, Georgia, Kansas and Texas – allow public school employees to carry firearms to work, according to the National Conference of State Legislatures.

President Donald Trump has voiced support for arming teachers and so has the NRA.

The Florida bill also included a provision to make it easier for police to confiscate weapons from anyone found to pose a threat of violent behaviour.

This so-called “red flag” measure has also been proposed by five other states – Rhode Island, Utah, Kentucky, Alabama and Pennsylvania – since last month’s Parkland attack, according to the Brady Campaign to Prevent Gun Violence.