Crowds take part in the morning service at Emanuel African Methodist Episcopal Church in Charleston, June 21, 2015. REUTERS/Carlo Allegri

CHARLESTON, S.C. (Reuters) – A South Carolina man will plead guilty to federal charges he lied to investigators and concealed knowledge of his friend’s plans for a deadly mass shooting that killed nine parishioners at a Charleston church last year, court papers showed on Monday.

Joseph Meek, 21, will plead guilty to two charges, according to a plea agreement filed in federal court. He was indicted for lying to an FBI agent after his childhood friend, 22-year-old Dylann Roof, allegedly opened fire during a June 17 Bible study at the historic Emanuel African Methodist Episcopal church.

An attorney for Meek and federal prosecutors declined to comment.

Court documents show Meek has agreed to cooperate with U.S. attorneys. He could be called to testify at Roof’s trial to his knowledge of his friend’s alleged crimes.

A hearing to change his plea is scheduled for Friday in U.S. District Court in Charleston. If a judge accepts the deal, Meek would avoid a trial that was set to start in late June.

Meek faces a maximum of eight years in prison, four years of supervised release and more than $500,000 in fines on the two counts.

Roof faces 33 federal charges including hate crimes, obstruction of religion and firearms offenses. Authorities have said evidence showed he had white supremacist views and that he targeted the victims because of their race.

Both Roof and Meek are white. The victims of the church shooting were black.

Roof’s federal trial has been delayed repeatedly while U.S. prosecutors decide whether to seek the death penalty. Defense attorneys have said Roof will plead guilty if he does not face the possibility of execution.

South Carolina prosecutors have also charged him with nine counts of murder, as well as with attempting to murder three people who survived the rampage, and he faces the death penalty.

(Reporting by Harriet McLeod; Writing by Colleen Jenkins and Letitia Stein; Editing by Chris Reese, Cynthia Osterman and David Gregorio)