WASHINGTON - A white gunman was arrested on Thursday after fatally shooting at least nine worshippers in a historic black church in a southern US city in what police called a hate crime.

Churchgoers had gathered for a prayer meeting in the Emanuel African Methodist Episcopal Church on Wednesday evening in Charleston, South Carolina when the shooter walked in, sat in the congregation for about an hour, then opened fire, Charleston Police Chief Gregory Mullen said.

The suspect has been identified by police and the FBI, according to American media reports.

Dylann Roof, a 21-year-old white man, has had police record - he was arrested twice in South Carolina, including a first-offense drug possession charge in March. He was also arrested April 26 on a trespassing charge.

Police said he walked into the church and fatally shot nine people, six females and three males, as they attended Bible study class. The FBI and Justice Department’s Civil Rights division are investigating the shooting as a hate crime.

President of National Association for the Advancement of Colored People (NAACP) Cornell William Brooks said, “The NAACP was founded to fight against racial hatred, and we are outraged that 106 years later, we are faced today with another mass hate crime. Our heartfelt prayers and soul-deep condolences go out to the families and community of the victims at Charleston’s historic Emanuel AME Church. The senselessly slain parishioners were in a church for Wednesday night Bible study. There is no greater coward than a criminal who enters a house of God and slaughters innocent people engaged in the study of Scripture.”

The shooting was reminiscent of the 1963 bombing of an African-American church in Birmingham, Alabama, that killed four girls and fueled the civil rights movement of the 1960s.

America’s latest mass shooting comes at a time of heightened racial tensions in the country, after several high-profile killings of unarmed black men at the hands of white policemen in recent months led to riots and a national debate on race.

Among the dead was the church’s pastor Clementa Pinckney, who was also a South Carolina state senator, fellow politician Marlon Kimpson told US media.

Police said the suspect was a clean-shaven white man in his early 20s. As of 7:00 am Thursday (1100 GMT), he remained at large and officers swarmed the city with the help of helicopters and tracking dogs to try to find him.

Police released security camera images of the suspected gunman - a slender young white man with dark blond or brown hair in a distinctive bowl-type haircut, and wearing a grey sweater.

Jim Curley, owner of AC’s Bar & Grill, which is located a few blocks from the church, said locals were shocked anyone would carry out an attack in the popular tourist area.

“This is absolutely bizarre,” Curley told AFP. “This is really completely out of the blue... We have no idea what the motivation is.”

The shooting’s designation as a hate crime means federal authorities will help with the investigation and could assist in an eventual prosecution.

Officers also investigated a possible bomb threat after the shooting, but several hours later gave the all-clear.

The incident once again brings to the fore broad racial tensions that persist in many US communities, more than five decades after the Civil Rights Act was enacted to outlaw racial and other forms of discrimination.

High-profile police killings of unarmed black men have prompted riots, as well as much soul-searching and national debate in recent months as America grapples with its troubled racial past.

In April, in the neighboring city of North Charleston, a white police officer was charged after a video surfaced of him fatally shooting a fleeing black man, 50-year-old Walter Scott, in the back.

But Curley said the neighbourhood’s residents typically get along fine.

“Generally, there’s not a great deal of racial tension,” he said.

Because of the shooting, Republican presidential candidate Jeb Bush cancelled campaign events that had been planned for Thursday in Charleston.

“Governor Bush’s thoughts and prayers are with the individuals and families affected by this tragedy,” his campaign said in a statement.

Democratic presidential candidate Hillary Clinton, who had been in Charleston earlier Wednesday, tweeted her condolences. “Heartbreaking news from Charleston - my thoughts and prayers are with you all,” she wrote.