But this is Florida, a laboratory for the N.R.A. and a state that has become recognized for its consistent efforts under legislative Republican control since 1996 to expand gun rights. For example, residents only have to comply with a simple protocol to obtain permits to carry concealed weapons. And Florida has embraced “Stand Your Ground” laws that protect the use of deadly force in public.

That such a gun-friendly state adopted any firearm restrictions represents a sea change, even more so as the restrictions were drafted and approved in a matter of three weeks, after a bipartisan vote and the signature of a Republican governor likely to be on the ballot later this year as a Senate candidate.

“If you would have had this conversation with me before session, I would’ve said it’s just not going to happen,” said Senator René García, a moderate Republican from the Miami area who has served 16 years in the Legislature. “Not only did we get this bill passed, but the fact that we had debate on these amendments on the floor was huge. I don’t remember having these debates on the floor ever before.”

The N.R.A. has had to contend with other states also considering action since the Parkland shooting. In Illinois, lawmakers passed a bill last week that would require gun dealers to be licensed by the state, but it was not clear whether the Republican governor would sign it into law. In Vermont, lawmakers advanced legislation that would raise the minimum age to buy a gun to 21 and allow for judges to seize guns from people deemed dangerous.

Elsewhere, legislators took steps toward expanding the legal use of firearms. In Mississippi, state senators approved a bill on Wednesday that would allow trained school employees to carry concealed weapons. And in Missouri, a House committee last week advanced a bill that would allow people with concealed-carry permits to have a weapon in so-called gun-free zones.

The law’s passage came as a surprise to many in Florida, where lawmakers had failed to enact legislation after the mass shooting at the Pulse nightclub in Orlando in 2016, which left 49 dead, and the shooting at the Fort Lauderdale airport that killed five people in 2017. The governor mentioned both crimes on Friday.

Lawmakers like Representative Carlos Guillermo Smith, a Democrat from Orlando, voted against the bill because it did not include a ban on assault weapons or other broad measures sought by survivors of all the shootings.