Lawyers for the National Rifle Association are locked in a dispute with the New York Attorney General's Office, with the gun-rights advocacy group aiming to block the government's subpoena for records from the advertising agency Ackerman McQueen, where the NRA had a contract until recently.

The NRA's contract with the ad agency included a nondisclosure agreement. Assistant New York Attorney General Monica Connell argued the NDA is being used to chill cooperation by Ackerman and potentially other organizations with the state's investigation into the NRA.

"[Ackerman is] essentially under a sword of Damocles," Connell told New York County Supreme Court Justice Melissa Crane in court Thursday.

The Attorney General's Office is asking Crane to compel the ad agency to comply with the subpoena without allowing the NRA to review the produced documents in advance.

Ackerman's records include extensive privileged material related to its work with the NRA, NRA attorney Sarah Rogers, a partner in the New York office of Brewer, Attorneys & Counselors, argued.

Rogers said Ackerman's relationship with the NRA is unique because the agency routinely communicated with the NRA's general counsel about legal matters, such as how to present information about gun laws on websites that Ackerman maintained for the NRA.

Crane appeared to express skepticism about whether communications between the NRA general counsel and Ackerman were privileged.

It "seems awfully dangerous to do that if you're interested in privilege protection," she said after Rogers described one example of how the general counsel emailed advice to NRA and Ackerman employees.

The NRA is also concerned that its donors' identities could become public through the subpoena, Rogers said.

She referenced the 1958 Supreme Court decision NAACP v. Alabama, which found that the NAACP's membership list could not be scrutinized by the state; Connell noted that the subpoena is not aimed at membership lists and the Attorney General's Office may uncover donor information as part of its typical regulation of nonprofits.

While the NRA is not willing to waive the nondisclosure agreement, Rogers said, she argued that Ackerman's responsibilities toward the NRA also rely on common law.

"The disputed NDA provision codifies, but does not materially alter, [Ackerman's] confidentiality obligations as an agent to its former principal, the NRA," she wrote in a memo last week. "As such, [Ackerman] continues to have an active and ongoing fiduciary duty to the NRA, which includes a duty to preserve the confidentiality of the NRA's information absent the NRA's consent."

Connell emphasized that the Attorney General's Office is responsible for regulating nonprofits located in New York, including the NRA. The NRA cannot use an NDA to shield its conduct from its regulator, she said.

William Brewer III, a Dallas-based partner at Brewer, Attorneys & Counselors who is representing the NRA, said in a statement that the Attorney General's Office is trying to conduct a secret investigation. Compelling Ackerman's compliance without NRA review would be "an unprecedented, alarming expansion of the government's power," Brewster said.

Rogers said in court that the government has the right to conduct confidential investigations. In a statement released after Thursday's hearing, Attorney General Letitia James said the NRA has no authority to act as a gatekeeper, and her office won't let the organization keep "a set of virtual eyes and ears" on the investigation.

Lawyers from McDermott Will & Emery, which is representing Ackerman, were in court Thursday but did not speak, and a firm spokeswoman declined to comment on the case.