National Republican leaders have been eager to put the debate over the Confederate flag behind them. But on the same day that South Carolina finally voted it off its state capitol grounds, the flag somehow managed to bring down a $30 billion spending bill in Congress.

It’s hard to understand exactly how Republican leaders in the House allowed the divisive symbol to derail an appropriations bill for the EPA and the Department of the Interior, but by midday Thursday, they were forced to shelve a piece of legislation that just a day earlier had been set to pass—all because of the flag.

What happened is this: Seizing on the emotional debate playing out in states throughout the South, House Democrats on Wednesday offered amendments that would prohibit the use of public funds to display the Confederate flag on federal lands—specifically at cemeteries run by the National Parks Service.  Hoping to avoid any kind of dispute surrounding the flag, GOP lawmakers in charge of the legislation adopted the amendments by voice vote.

But not all Republicans were happy that Democrats had slipped in language targeting the Confederate flag. According to reports in the Beltway press, some members from Southern states complained to party leaders, promising to oppose the appropriations bill if the amendments stayed in. With most Democrats balking at the funding cuts and restrictions the bill would impose on the EPA, the Republican leadership could not afford to lose any votes.

Late Wednesday night, Representative Ken Calvert of California, the chief GOP author of the appropriations bill, surprised Democrats by introducing an amendment, slated to be voted on Thursday, that appeared to undo the changes already added and restore the Confederate flag to national cemeteries. Democrats were aghast. According to Roll Call, Representative Betty McCollum was “audibly shaken” as she rose to protest the move in a speech on the House floor. The chairman of the Congressional Black Caucus, G.K. Butterfield, took to the floor to express his “utter outrage”:

Don’t Republicans understand that the Confederate Battle Flag is an insult to 40 million African Americans and to many other fair-minded Americans?

By Thursday morning, Republican leaders decided that instead of risking a public debate over the flag, they would pull the entire spending bill from the floor. “This bill is going to sit in abeyance until we come to some resolution on this,” Speaker John Boehner told reporters at a press conference. While making clear he did not believe the Confederate flag should fly in federal cemeteries, he said he’d be forming a group of members that would look at the issue “in a responsible way.” Presumably, Boehner wants to find a way to simply remove the flag from federal areas, rather than allow Democrats to attach piecemeal provisions to other bills.

But Democrats were not having it. In the midst of unrelated votes later Thursday, Nancy Pelosi, the party leader, sought to force a vote on a resolution that would remove all flags that include the Confederate flag—such as the state flag of Mississippi—from display in the Capitol. Over the raucous objections of Democrats, Republicans voted to refer the resolution to committee, effectively tabling it. To protest, Democrats insisted on casting their votes manually, rather than using the now-traditional electronic method, slowing down the process.

Calvert, meanwhile, insisted on Thursday that the amendment was not his idea and that party leaders, under pressure from Southern Republicans, had put him up to it. In a lengthy statement, he said that existing Obama administration rules prohibited the sale and display of the Confederate flag, “except when displayed in a historical and educational context.” One of the Democratic amendments would have removed that exception, and the leadership amendment was meant “to clear up any confusion and maintain the Obama administration’s policies with respect to those historical and educational exceptions.” He said he regretted not consulting with Democrats “regarding this important and sensitive issue.”

“To be clear,” Calvert said in a part of his statement that was typed in bold, “I wholeheartedly support the Park Service’s prohibitions regarding the Confederate flag and the amendment did nothing to change these prohibitions.”

As the imbroglio unfolded in the U.S. Capitol, about 500 miles to the south, members of the South Carolina House of Representatives finally voted to remove the Confederate flag from the capitol grounds. At his press conference Thursday morning, Boehner said he scrapped the spending bill because he did not want the Confederate flag issue to become “a political football.” Judging by the theatrics in the House on Thursday, it might be a little late for that.