FALL RIVER — A provision in the gun reform bill that the Legislature passed just before their session ended Thursday night will make it easier for prosecutors to convict and secure longer prison sentences for defendants who shoot at someone, officials said.

“It was a late victory [Thursday] night for the people of Massachusetts and for law enforcement,” said Bristol County District Attorney Samuel Sutter, who lobbied lawmakers for more than seven years to enact legislation that creates two new criminal charges: assault and battery by means of discharging a firearm, and attempted assault and battery by means of discharging a firearm.

Sutter said the new offenses will “fill a critical gap” for prosecutors and enable them negotiate longer prison sentences in plea deals without having to go to trial. The district attorney added that having new gun crimes on the books will also help deter street-level gun violence.

In a letter he sent to state lawmakers, Sutter argued that 37 states had already enacted statutes creating new penalties for gun-related crimes, including specific laws banning nonfatal drive-by shootings.

“These states all recognize the exceptional severity of a violent assault and battery committed by firing a gun,” Sutter wrote. “Now, with this gun violence bill, it is time for Massachusetts to do the same.”

The new charge of assault and battery by means of discharging a firearm carries a 20-year maximum prison sentence, $10,000 fine or a 2½-year House of Correction sentence, while the attempted assault and battery by means of discharging a firearm has a maximum 15-year prison sentence or a 2½-year House of Correction sentence.

“We won’t be recommending any House of Correction sentences for shootings,” said Sutter, who said the new criminal charges were needed to correct a conundrum that prosecutors have had when deciding how to charge someone accused of shooting at someone, but not killing them.

Until now, prosecutors could choose to charge a defendant with armed assault with intent to murder, which is difficult to secure a conviction because prosecutors have to prove a specific intent to kill someone.

The other charge prosecutors have been filing against defendants in a shooting was assault and battery with a dangerous weapon, an offense that carries a 10-year maximum sentence. However, sentencing guidelines instruct judges to impose a 3½- to 5-year sentence for people with minor or moderate criminal records.

A defendant younger than 30 who is convicted of a gun crime often has not compiled a lengthy criminal record that warrants longer prison sentences under the assault and battery with a dangerous weapons statute. Sutter said his office conducted an internal survey of shooting cases in Bristol County that showed 70 percent of shooters are younger than 25.

Page 2 of 2 - “Most haven’t been adults long enough to compile violent and serious-violent records,” said Sutter, who thanked members of the local state legislative delegation who were “extremely helpful” in passing the new law.

Rep. Antonio F.D. Cabral, D-New Bedford, pushed the measure in the House of Representatives, and said he believes it “will help tremendously.”

“It will facilitate convictions of individuals guilty of these kind of crimes,” Cabral said. “I think this will really put a dent in crime, and we will be able to put away, for longer periods of time, individuals that commit crimes with firearms.”