ALBANY, N.Y. (AP) — New York's legislature passed legislation Thursday banning anyone under age 21 from buying or possessing a semi-automatic rifle, a major change to state firearm laws pushed through less than three weeks after an 18-year-old used one of the guns to kill 10 people at a supermarket in Buffalo.

The Legislature spent Thursday evening debating the bill raising the age limit, which passed the Senate along party lines 43-20 and in the Assembly 102-47. The legislation, which also launches a licensing requirement, is the centerpiece of a package of gun control bills announced earlier this week by Democratic legislative leaders and Gov. Kathy Hochul. It's now set to head to Hochul's desk for her signature.

New York already requires people to be 21 to possess a handgun. Younger people would still be allowed to have other types of rifles and shotguns, but the change in the law would restrict ownership of the type of fast-firing rifles used by the 18-year-old gunmen in the mass shootings in Buffalo and at a Texas elementary school.

Besides raising the legal purchase age to 21, the bill would also require anyone buying a semiautomatic rifle to get a license — something now only required for handguns.

Republicans chastised Democrats for pushing a more sweeping measure than Hochul originally pitched.

Sen. Gustavo Rivera, a Bronx Democrat, rebuffed Republicans who argued the bill will inconvenience gun owners and infringe Second Amendment rights: “It is meant to be a hassle to those folks who might want to get their hands quickly on something with which they could mass murder people”

Semiautomatic rifles automatically load each bullet after firing, although firing requires pulling the trigger for each round. That makes it possible for mass murderers to kill more people in a short amount of time.

The change would largely impact areas outside New York City, which already requires permits to possess, carry and purchase any type of firearm and prohibits most applicants under 21.

Elsewhere in New York, people as young as 16 can possess long guns like rifles and shotguns without a license.

Sen. Alexis Weik, a Republican of Long Island, pointed out that an 18 year old could still travel to another state and buy a semi-automatic rifle.

Sen. Kevin Thomas, a Long Island Democrat and one of the bill's sponsors, replied, “Are you advocating for federal gun control? Because that what's needed."

New York would join a handful of states — including Florida, Hawaii, Illinois, Vermont and Washington - that require buyers to be at least 21 instead of 18 to purchase some types of long guns. Similar legislation has been proposed in Utah.

California's attempt to raise the legal buying age for a semiautomatic weapons has been challenged in court.

On May 11, a U.S. Appeals court panel ruled 2-1 that the state’s ban on the sale of semiautomatic weapons to adults under 21 is unconstitutional. The two judges who ruled in the majority were part of Republican President Donald Trump’s wave of conservative-approved nominees that reshaped the famously liberal court.

The National Rifle Association is also challenging Florida's ban on the sale of rifles and other firearms to adults under age 21, which was passed in the wake of a 2018 shooting that killed 17 students and staff at a high school in Parkland.

Another bill set to pass in New York would require new guns to be equipped with microstamping technology, which would allow law enforcement investigators to more easily link weapons to fired bullets.

The state is also expected to pass legislation that would restrict the purchase of body armor and expand the list of people who can apply for an extreme risk protection order, a court order that can temporarily prohibit someone from purchasing or possessing a firearm if they are believed to be a danger to themselves or others.