By Harriet McLeod

CHARLESTON, South Carolina (Reuters) -- An attorney for the man accused of gunning down nine people at a historic black church in South Carolina in June said on Wednesday his client is willing to plead guilty to state murder charges if that would spare him a death sentence.

A guilty plea by Dylann Roof, 21, in exchange for a sentence of life in prison without parole also would spare the victims' families and survivors of the shootings from the trauma of trial proceedings, Roof's attorney Bill McGuire said.

His remarks came during a hearing in Charleston over whether a judge will release 911 emergency telephone calls and police 8reports about the June 17 massacre during a Bible study meeting at Charleston's Emanuel African Methodist Episcopal church.

Prosecutors declined to comment afterward on whether they would accept a guilty plea from Roof, who is white and has been linked to white supremacist views.

Judge J.C. Nicholson in July blocked the release of investigative materials in the state's murder case against Roof, citing concerns about graphic photos of the crime scene and emergency calls that might have recorded the sounds of victims.

Nicholson did not rule on Wednesday but indicated he would likely release some materials.

Assistant U.S. Attorney Nathan Williams, who is prosecuting Roof in federal court, argued on Wednesday for keeping the documents sealed. He said the families and survivors were "re-traumatized" every time they heard or read about the killings.

"It may take years before people are ready to see that," he said.

Media outlets asked the judge to lift his gag order, arguing that transparency ensures a defendant's right to a fair trial.

In addition to state murder charges, Roof faces 33 federal hate crime and weapons charges that also could result in a death sentence.

The federal charges are based on evidence that Roof targeted the black victims because of their race and "in order to interfere with their exercise of religion," according to U.S. Attorney General Loretta Lynch.

At Roof's federal arraignment in July, his attorney said Roof wanted to plead guilty to those charges but his defense team was waiting until prosecutors decided whether they would seek the death penalty in their case.

The State newspaper reported on Tuesday that a friend who gave Roof a place to stay in the weeks ahead of the killings is a "potential target" in the federal investigation.

Joseph Meek Jr. is being investigated for allegedly making false statements and concealing knowledge of a crime from authorities, the paper said, citing a letter Meek received from the FBI.

(Reporting by Harriet McLeod; Editing by Colleen Jenkins, Will Dunham and Bill Trott)