A $67 million voluntary school “marshal” program would allow school superintendents to work with local sheriffs to train and arm designated personnel on campus. The restriction adopted on Monday would eliminate the “vast majority” of school staff from participating, said the sponsor of the legislation, Senator Bill Galvano, a Republican. His $400 million legislative package also contains funding for school safety and mental health programs, and numerous gun control measures opposed by the National Rifle Association. It now heads to the State House for approval.

But the legislation, written and advanced unusually quickly after last month’s deadly shooting in Parkland, Fla., would still bring more guns into schools in districts that opt into the marshal program. That was not among the far-reaching demands for gun control pushed by student activists after the shooting. However, lifting gun-free safe zones in schools has been a longtime goal of the N.R.A.

“This is fulfilling part of the N.R.A.’s dream,” lamented Senator José Javier Rodríguez, a Democrat whose party is far outnumbered in the State Capitol.

Still, not even Mr. Rodríguez could bring himself to vote against the amendment scaling back the marshal program. Not a single Democrat said “no” when Joe Negron, the Senate president, asked for a voice vote. The amendment, despite allowing for librarians, counselors and coaches to carry guns, was still the biggest concession Democrats got from Republicans on the legislation. Mr. Scott, Mr. Negron and House Speaker Richard Corcoran have made passing the gun package a priority before the annual legislative session ends on Friday.

In the end, a majority of senators decided some action was better than none — even if the legislation is disliked by Democrats who oppose arming any school personnel, and by Republicans who oppose enacting any new gun restrictions. The legislation passed, 20-18, with three Democrats voting in favor, and six Republicans against.