A US federal judge has upheld New York's ban on military-style semiautomatic weapons handing a victory to gun control advocates.

Judge William M. Skretny of Federal District Court in Buffalo ruled that the ban on high capacity semi-automatic weapons does not violate the second amendment right to bear arms, as claimed by the New York State Rifle and Pistol Association.

In a 54-page document, Judge Skretny wrote:"Studies and data support New York’s view that assault weapons are often used to devastating effect in mass shootings."

Download the new Independent Premium app Sharing the full story, not just the headlines

The New York Safe Act, approved in the wake of the Sandy Hook Elementary School shooting where 20 children and six adults were killed, expanded the state's ban on semi-automatic weapons that resemble assault rifles and high-capacity magazines.

He also highlighted that the ban "applies only to a subset of firearms with characteristics New York State has determined to be particularly dangerous and unnecessary for self-defense; it does not totally disarm New York’s citizens; and it does not meaningfully jeopardize their right to self-defense."

Judge Skretny did, however, struck down a controversial provision limiting the number of bullets in a magazine to seven, which he described as "arbitrary".

Gun-rights supporters are expected to take the case to the US Supreme Court.