South Carolina Gov. Nikki Haley (R), center, being applauded after signing the bill. (Sean Rayford/Getty Images)

South Carolina Gov. Nikki Haley signed a bill Thursday ordering the removal of a Confederate battle flag flying near the state Capitol, a remarkable event that would have been inconceivable just weeks ago.

“The Confederate flag is coming off the grounds of the South Carolina statehouse,” Haley, a Republican, said at a packed news conference in Columbia.

In her remarks Thursday, Haley spoke of the nine victims of last month’s church shooting in Charleston and their relatives, who offered the accused gunman forgiveness and prayer last month. This compassion, she said, helped lead the state’s legislature to send her the bill allowing for the flag to be taken down.

“This is a story about action,” she said. “This is a story about the history of South Carolina. And how the action of nine individuals laid out this long chain of events that forever showed the state of South Carolina what love and forgiveness looks like.”

[Remembering the nine victims of the Charleston church shooting]

Haley used nine different pens to sign the bill Thursday afternoon, saying that after the signing, each pen would be sent to the families of the nine church victims. She was surrounded by dozens of victims’ relatives, lawmakers and other officials who burst into loud applause after she finished signing the bill into law.

“So 22 days ago, I didn’t know that I would ever be able to say this again,” she said, speaking of the time since the church massacre took place. “Today, I am very proud to say that it is a great day in South Carolina.”

South Carolina Gov. Nikki Haley (R) dedicated the nine pens used to sign a bill to remove the Confederate flag from state grounds to the families of those killed in the church shooting in Charleston. (AP)

Haley signed the bill a little more than two weeks after reversing her earlier position and calling for the flag to come down, providing a powerful impetus for state lawmakers to take up the issue.

Early Thursday morning, the state House of Representatives agreed to send the bill to Haley following 13 hours of increasingly contentious debate. Lawmakers spent long periods discussing possible amendments, offering personal speeches and, at times, directing emotional pleas to their fellow representatives.

“I saw passions get high, I saw passions get low, but I saw commitment neverending,” Haley said Thursday.

The confederate flag flies on the grounds of the South Carolina State House in Columbia, South Carolina, June 27, 2015. There has been a growing clamor for the flag -- branded "a reminder of systemic oppression and racist subjugation" by President Barack Obama on Friday -- to be removed from the grounds of the state house in Columbia. Once flown by the rebel army of the slave-owning South, the confederate flag is seen by some as a symbol of regional heritage, but by many more as an ugly reminder of racism's cruel legacy. AFP PHOTO/JIM WATSONJIM WATSON/AFP/Getty Images The Confederate flag on the statehouse grounds. (Jim Watson/AFP/Getty Images)

According to the bill, the flag has to come down within 24 hours of Haley’s signature. She said it will be removed Friday at 10 a.m. and taken from the flagpole to a Confederate relic room.

On Thursday, while praising those who voted to take down the flag, she also paused to be respectful of a symbol that many in the state and beyond have continued to defend as criticism of the flag mounted recently.

“We are a state that believes in tradition,” she said. “We are a state that believes in history. We are a state that believes in respect. So we will bring it down with dignity, and we will make sure it’s put in its rightful place.”

[For some in South Carolina, confusion and anger over the Confederate flag’s unpopularity]

South Carolina’s flag had seemed all but immovable just a month ago, but it suddenly became the nexus of controversy after a gunman shot and killed nine parishioners inside the Emanuel African Methodist Episcopal Church in Charleston. A racist manifesto found online belonging to Dylann Roof, the alleged gunman, was littered with references to the Confederacy and images of the Confederate flag.

In the days and weeks after the church massacre, a growing chorus of voices criticized the flag’s prominent position near the Capitol, while antipathy toward Confederate imagery spread remarkably quickly across the South.

“The confederate battle flag as a symbolic stain of racism has been dismissed from the state Capitol grounds and may now be deposited to a museum,” Cornell William Brooks, president and chief executive of the NAACP, said in a statement on Thursday. “This flag should be studied and no longer honored.”

This debate also surfaced on Capitol Hill in Washington, as lawmakers battled Thursday over the Confederate flag’s placement in federal cemeteries for veterans. House Speaker John Boehner (R-Ohio) said he would create an informal, bipartisan group to look at any displays of Confederate memorabilia — including, most likely, those in the U.S. Capitol.

Meanwhile, South Carolina state law had previously dictated that the flag has to be flown at the Confederate Soldier Monument, which was dedicated in 1879 to honor those who died during the Civil War. In 2000, as another debate over the flag raged, the state legislature passed a bill moving the flag from the Capitol dome and placing it near the monument.

Haley, like numerous other politicians who have recently called for the flag’s removal, had not previously seemed amenable to moving it, but her position changed in the wake of the church shooting.

This post has been updated. First published: 4:25 p.m.