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 July Sean 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.

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.

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 Statehous Getty/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 2015 Adam 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.