The 20-18 vote followed three hours of often emotional debate, and came in response to last month’s deadly school shooting.
Support and opposition crossed party lines, and it was clear many of those who voted for the bill were not entirely happy with it.
“Do I think this bill goes far enough? No! No, I don’t!” said Democratic Senator Lauren Book, who tearfully described visiting Marjory Stoneman Douglas High School after 17 people were fatally shot on Valentine’s Day.
She also would have liked a ban on assault-style rifles, like many of the students who travelled to the state Capitol to ask politicians to go even further to stop future mass shootings.
But Ms Book said she could not let the legislative session end on Friday without doing something.
“My community was rocked. My school children were murdered in their classrooms. I cannot live with a choice to put party politics above an opportunity to get something done that inches us closer to the place I believe we should be as a state,” she said.
“This is the first step in saying never again.”
Earlier on Monday, families of the 17 Florida high school massacre victims called on the state’s legislature to pass a bill they believed would improve school security.
Reading a statement outside Stoneman Douglas High School in Broward County, Ryan Petty implored politicians to pass Governor Rick Scott’s proposal to add armed security guards, keep guns away from the mentally ill and improve mental health programmes for at-risk teenagers. Mr Scott also opposes arming teachers.
“We must be the last families to lose loved ones in a mass shooting at a school. This time must be different and we demand action,” said Mr Petty, reading from the group statement.
If just one more senator had voted no instead of yes on Monday evening, the bill would have died.
Republicans and Democrats alike said there were parts of the bill they did not like.
Democrats did not like the idea of letting teachers carry guns, even if the bill was amended to water down that proposed programme.
And many pro-gun rights Republicans did not like the idea of raising the minimum age to buy rifles from 18 to 21 and to create a waiting period on sales of the weapons.
The Senate amended its bill to limit which teachers could volunteer to go through law enforcement training and carry guns in schools.
Any teacher who does nothing but work in a classroom would not be eligible for the programme, but teachers who perform other duties, such as serving as a coach, and other school employees could still participate.
Other exceptions would be made for teachers who are current or former law enforcement officers, members of the military or who teach in a Junior Reserve Officer’s Training Corps programme.
In addition to the gun restrictions and arming some school personnel, the bill would create new mental health programmes for schools, improve communication between schools, law enforcement and state agencies, create a task force to look at mistakes made during mass shootings nationally and then make recommendations on how to continue to improve law, and establish an anonymous tip line where students and others can report threats to schools.
The bill now goes to the House, which has a similar bill still waiting for consideration by the full chamber. The annual 60-day session is scheduled to end on Friday.