SANTA FE, N.M.—In swaths of rural America, county sheriffs, prosecutors and other local officials are mounting resistance to gun-control measures moving through legislatures in Democratic-led states.

The “Second Amendment sanctuary” movement has taken hold in more than 100 counties in several states, including New Mexico and Illinois, where local law-enforcement and county leaders are saying they won’t enforce new legislation that infringes on the constitutional right to bear arms.

For...