A spokeswoman for the state attorney general said that his office had “expected a legal challenge” and was “fully prepared to defend the law.”