South Carolina has passed a bill to remove the Confederate battle flag from its state capitol grounds after an emotional 13-hour debate. The flag, which dates back to the 1861-65 American Civil War, is a symbol of slavery and racism to some, and of Southern heritage to others.

confederate flag south carolina
The Confederate battle flag flies outside the South Carolina state house in Columbia on 8 JulySean Rayford/Getty Images

The final vote was secured exactly three weeks after nine black worshippers were gunned down on 17 June during Bible study at a church with an historically black congregation in Charleston. Days later, photos surfaced of the suspected gunman, Dylann Roof, posing with a Confederate flag on a website bearing a racist manifesto.

Dylann Roof Last Rhodesian website 9
Roof poses with a Confederacy flag. The same flag is flown over the state capitol of South Carolina.Dylann Roof
confederate flag south carolina
A man takes part in a protest rally against the Confederate flag in Columbia, South Carolina on 20 June 2015. The racially divisive Confederate battle flag flew at full-mast despite others flying at half-mast after the killing of nine black people in an historic African-American church in Charleston on 17 JuneMladen Antonov/AFP

There were hugs, tears and high fives in the House chamber after the vote. Governor Nikki Haley has promised to sign the bill quickly. The bill requires the flag be taken down within 24 hours of her signing before being shipped to a local history museum.

confederate flag south carolina
State Representatives John King and Cezar McKnight celebrate after the House approved a senate bill to remove the Confederate battle flag from the South Carolina capitol groundsSean Rayford/Getty Images
confederate flag south carolina
Left: The Reverend Jesse Jackson celebrates at the South Carolina state house on 9 July 2015. Right: He takes part in a protest against the association of the Confederate flag in the Georgia state flag in January 1994Getty/AFP

The flag was first flown over the dome of South Carolina's Capitol in 1961 to celebrate the 100th anniversary of the war. It stayed as a protest to the Civil Rights movement that sought to end discrimination against blacks, only moving in 2000 from the dome to its current location.

confederate flag south carolina
Left: The Confederate flag flies over the South Carolina capitol building in Columbia on 18 February 2000. Right: South Carolina Governor Jim Hodges takes the flag after it was removed from the Statehouse dome. A smaller version was raised moments later in front of the StatehousGetty/AFP

On 27 June an activist climbed the flagpole and took down the Confederate flag. Two people were arrested and charged with defacing a monument.

confederate flag south carolina
Brittany "Bree" Newsome is arrested after climbing a flagpole outside the South Carolina state capitol and taking down the Confederate flag on 27 June 2015Adam Anderson/Reuters

A spokesman for Governor Nikki Haley says the Confederate flag will be removed from the South Carolina Statehouse grounds on Friday morning (10 July).

Opponents of removing the flag lamented that the flag had been "hijacked" by racists.

confederate flag south carolina
Pro- and anti-Confederate flag campaigners argue outside the South Carolina Statehouse in ColumbiaSean Rayford/Getty Images
confederate flag south carolina
Pro-Confederate flag demonstrator Alice Horky wears Rebel flag cowboy boots on the South Carolina State House steps in ColumbiaJim Watson/AFP
confederate flag south carolina
Demonstrators campaign to remove the Confederate flag from the South Carolina state house grounds in ColumbiaSean Rayford/Getty Images