New Mexico's attorney general has warned sheriffs and police chiefs across the state that they must enforce new gun laws or risk legal liability.

New legislation, which will take effect this summer, requires background checks for all gun sales, even those between two individuals. Law enforcement leaders throughout the state opposed the measure as it was being debated in the legislature, and some said they would not enforce the law, according to The Albuquerque Journal .

Attorney General Hector Balderas' warning comes after at least 26 New Mexico counties passed " Second Amendment sanctuary " resolutions in opposition to guns laws decided by state lawmakers this year, including the measure requiring background checks.

Counties in several states, including Colorado and Illinois, have passed similar resolutions recently in opposition to newly passed or potential gun restriction measures.

Balderas, a Democrat, wrote in a letter to the state's law enforcement agencies that it was their duty to enforce the measures.

"As law enforcement officials, we do not have the freedom to pick and choose which state laws we enforce," Balderas said, according to The Albuquerque Journal.

Balderas also said that a police chief or sheriff who refused to enforce the measure could be held liable if a gun sale leads to a prohibited person owning a gun and doing harm.

Gun Control and Gun Rights Cartoons View All 314 Images

Cibola County Sheriff Tony Mace, who is also the president of the New Mexico Sheriffs' Association, said law enforcement officers already have discretion in how they enforce the law, and said officers are paying attention to what the people in their communities want.

All but a few of the state's 33 sheriffs oppose gun legislation passed this year by the Democratic-controlled legislature, The Albuquerque Journal reports. Along with the background check bill, lawmakers passed a measure prohibiting the possession of firearms by domestic abusers.

Critics say the background check bill – which has exceptions for guns sales between close family members and law enforcement officers – will make it harder for law-abiding gun owners to buy guns, while criminals will simply ignore it.