DENVER (Reuters) - A federal judge upheld gun laws on Thursday introduced by Colorado in the wake of deadly shooting rampages there and in Connecticut, dismissing a lawsuit filed by sheriffs, gun shops, outfitters and shooting ranges.

U.S. District Chief Judge Marcia Krieger issued her ruling after a two-week civil trial in Denver. The measures signed into law by Governor John Hickenlooper in 2013 included banning ammunition magazines with more than 15 rounds.

The bills were introduced in response to a shooting spree in 2012 that killed 12 people at a suburban Denver movie theater and the slaying the same year of 20 children and six adults at an elementary School in Newtown, Connecticut.

They immediately met resistance from critics, including most of the state’s elected sheriffs, who said they severely restricted citizens’ constitutional right to own and bear arms.

The measures, passed by Colorado’s Democratic-controlled legislature with scant Republican support, also required background checks for all private gun sales and transfers. The sheriffs said they had insufficient resources to police them.

Colorado’s Republican Attorney General John Suthers said in a statement his office never claimed the laws were “good, wise or sound policy,” but that it had fulfilled its responsibility to defend the constitutionality of the state law in question.