Image copyright AP Image caption Joey Meek cried as his sentence was read in court

A friend of the Charleston gunman who killed nine worshippers at an African-American church has been jailed for lying to police about the tragedy.

Before his sentencing, 22-year-old Joey Meek tearfully told the court he was not sure if he would survive in prison.

"I'm really, really sorry. A lot of beautiful lives were taken," he told bereaved relatives gathered in court.

His friend, Dylan Roof killed nine worshippers during a Bible study in a church in South Carolina.

Meek pleaded guilty to lying to the FBI and failure to report a crime.

"I don't know if I'll make it out of prison alive. I'm scared," he added before the federal judge handed down his sentence of more than two years.

Prosecutors said that white supremacist Roof had told Meek about the plot a week before the attack.

He said Roof had shared his violent plans during a night at Meek's house as they drank vodka, took drugs and played video games.

In filing documents, his lawyer said that his "failure to appreciate the seriousness of Roof's statements is not unusual in today's shock value culture".

Media playback is unsupported on your device Media caption Dylann Roof's friend, Christon Scriven, said he "never said anything racist, never treated me any different"

Judge Richard Gergel said Meek's punishment should serve as a deterrent against anyone else who hears of a serious crime and fails to report it.

Meek's "failure to make an earlier report is tragic and deeply regrettable, but his failure to report was not a violation of federal criminal law," the judge wrote, having ruled earlier that Meek could only be prosecuted for his actions after the attack that claimed nine lives.

The judge added that "the danger he exposed to the community is extraordinary" because he did not call police to identify Roof as a suspect, and that Roof could have committed more attacks while on the run.

Meek's lawyer, Deborah Barbier, said in a statement outside the courtroom that "Joey sincerely hopes that anyone who has a friend who is talking about hurting someone will take it seriously, learn from his mistake and notify the proper authorities immediately''.

Meek and Roof both met at school but later drifted apart.

They rekindled their friendship when Roof contacted Meek on Facebook to say he had seen his mugshot online.

Meek had a previous criminal record for burglary.