NEW YORK (AP) — An appeals court has upheld New York City's law banning people with home handgun licenses from taking guns outside the city for target practice or to a second home.

The Friday ruling by the 2nd U.S. Circuit Court of Appeals kept intact a lower-court ruling concluding the Second Amendment was not infringed.

The New York State Rifle & Pistol Association and three individuals sued the city in 2015. Judge Robert Sweet said it was not unconstitutional for the city to restrict home gun owners. He noted handguns "in this and other large cities" are used for violent crimes.

The appeals court agreed, saying the law's purpose was to protect city residents.

Lawyers for the gun group and the three individuals did not immediately comment. The city said it was pleased.