A war among giant retailers that animated South Carolina politics the past few months has tipped in the direction of one of the most aggressive competitors: Amazon.com.

In mid-May, the South Carolina House of Representatives reversed itself and voted for a tax break aimed at attracting an Amazon distribution center in Cayce, just outside the capital of Columbia. It would come in the form of a five-year exemption to the company from collecting sales tax on merchandise that passes through the center and goes out to South Carolina customers. State officials estimate the break will cost the state treasury $10 to 15 million.

The vote was a significant defeat for Wal-Mart, , Home Depot, Target and other brick-and-mortar sellers who complained that their online rival was being given an unfair advantage.

South Carolina is the latest front in an escalating nationwide battle over whether and how states should seek to capture sales tax revenue generated by e-commerce.

With e-commerce comprising a growing share of economic activity, and states missing out on an increasing amount of sales tax revenue during a time of budget austerity, the stakes are high. In 2009, researchers at the University of Tennessee projected that state and local governments would lose $11.4 billion in fiscal year 2012 by not collecting sales tax on e-commerce transactions. The researchers pegged the six-year total loss from 2007-12 at $52 billion.

While the issue has intensified in recent years as states have become desperate for funds, it can be traced back to a 1992 U.S. Supreme Court case, Quill v. North Dakota, in which the Court concluded that a state cannot require vendors to collect sales and use taxes in a state unless they have a "physical presence" or "nexus" in that state. Rather, consumers are supposed to report their own sales tax liability for online purchases; but taxpayers rarely adhere to this requirement, and state enforcement is virtually nonexistent.

Amazon collects sales taxes in Kansas, Kentucky, New York, North Dakota and Washington State, where it has offices. In 2008, New York became the first state to require Amazon to collect sales tax based on the argument that local affiliates - independent vendors who market Amazon goods on their own Web sites - constitute a physical presence. Amazon sued New York and lost, but is now appealing that decision.

This past March, Illinois followed New York's lead. As he signed the "Main Street Fairness Bill" into law, Gov. Pat Quinn said it "will put Illinois-based businesses on a level playing field." Amazon responded by breaking ties with its Illinois affiliates. Similar events have unfolded in Rhode Island and North Carolina.

Amazon also has avoided paying sales taxes in states where its distribution centers are located, because they are typically owned and operated by separate corporate subsidiaries. But Texas Comptroller Susan Combs fired a new salvo against this practice in February, sending the company a tax bill for $269 million, on the grounds that Amazon's distribution center in the city of Irving established physical presence.

Amazon responded to Combs by threatening to shutter the warehouse and cancel plans to build additional facilities. The dispute will be decided by the State Office of Administrative Hearings. In the meantime, the Texas House and Senate passed bills clarifying the state's position that a distribution center constitutes physical presence. But Gov. Rick Perry vetoed the legislation.

Amazon's reaction in Texas illuminates a factor that provides it with important leverage: Distribution centers can be ramped up and down quickly. It does not take years to build one of these centers, or to shut it and walk away. If Amazon considers a state's tax policy to be onerous, it can quickly move across the border, often to another state that is willing to meet its terms.

Much of the political leadership in South Carolina still sympathizes with the critics. That includes Republican Gov. Nikki Haley, who has repeatedly argued that such exemptions are poor tax policy and discriminate not only against the big stores but against small independently owned businesses.

"Don't ask us to give you sales tax relief when we're not giving it to the bookstore down the street; or we're not giving it to the other stores on the other side of town," Haley said to Amazon at one point. "It's just not a level playing field."

Ironically, it was Haley's political mentor, former Gov. Mark Sanford, who pushed the deal forward in the first place. Just before he left office at the end of last year, Sanford signed off on the exemption, which was to come on top of the provision of a business site valued at $5 million, reduced property taxes and a 10-year, $3,250 tax credit for each job created.

A cost-benefit analysis completed by the South Carolina Commerce Department projected that Amazon will receive about $25 million over the next 10 years from economic development tax credits. That would be a direct cost to the state budget. On the other hand, the same study claimed that the exemption would yield the state in general a net gain of $232 million in the first year and $1.7 billion over 10 years.

The state House of Representatives, which didn't get a chance to vote on Sanford's proposal, at first sided with Haley. In late April, members of the House voted down the exemption. A majority of legislators effectively decided that the 1,249 jobs Amazon promised to create were not worth the costs that the exemption would impose on the state budget and retail competitors.

In making that decision, they were siding with the South Carolina Chamber of Commerce, as well as with the Alliance for Main Street Fairness, a Virginia-based advocacy coalition backed by Wal-Mart and the other big brick-and-mortar retailers. It began to look as if the huge Amazon warehouse, already in the process of being built, might stand unused for a long time.

It also began to look as if Wal-Mart had simply outlobbied Amazon. held a press conference days after the House vote and promised to build at least a dozen new stores and create 4,000 new jobs in South Carolina in the next five years.

But Amazon wasn't out of ammunition. It offered to sweeten its offer by increasing the number of employees to be hired at the Cayce facility from 1,249 to 2,000; Amazon also said it would increase its investment in the facility from $90 million to $125 million. On May 18, the South Carolina House changed its mind and voted for the exemption after all. The decision to support the revised package "ultimately came down to jobs," said state Representative Roland Smith.

The anti-exemption side was predictably upset by the reversal. Brian Flynn, speaking for the Alliance for Main Street Fairness, charged that the vote was "particularly disappointing in light of dubious, last-minute promises that certainly appear to have influenced some legislators to switch."

Perhaps most surprising was the stand Haley chose to take. She said she still thought the exemption was bad tax policy, but said she would not veto it and would let it become law without her signature.

The state Senate reached a late-night compromise last week on its version, which hinged on an agreement to require to inform customers that they may owe sales tax to the state, as well as to provide a link to the State Department of Revenue. The House quickly went along with the Senate version.

In the end, the solution may have to come from Washington. In April, U.S. Senator Dick Durbin, D-Ill., announced his intention to introduce a federal Main Street Fairness Act, which would require all online retailers to collect sales taxes regardless of whether the seller has a physical presence in the state. "Why should out-of-state companies that sell their products online have an unfair advantage over main street bricks-and-mortar businesses?" Durbin asked, echoing Haley's criticism in South Carolina.

Edward A. Zelinsky, a law professor at Yeshiva University in New York, believes that some states' actions against online retailers may overstep current constitutional law. But he believes they may pressure the federal government into passing legislation that would overturn the Quill decision and force the on-line companies to charge sales tax in every state.

"Through those laws," Zelinsky has written, "the states are essentially lobbying Congress."

Others are less confident that Congress will act on this issue because repealing the Quill decision would be perceived as raising taxes. David Brunori, a professor at George Washington University, thinks it's more likely that the U.S. Supreme Court will eventually overturn its ruling in Quill. A majority of justices, he says, may eventually decide that the status quo "doesn't make sense in the modern economy."