Under siege, Amazon shifts on taxes

FORTUNE — Amazon.com has long played hardball to avoid collecting sales tax from customers. States that failed to cooperate could count on a legal fight or threats by the company to close local warehouses.

But after years of digging in its heels, Amazon AMZN is slowly giving in. Over the next 18 months, the company will more than double the number of states in which it collects sales tax. Texas will be the first of eight states, starting on Sunday July 1, followed by Pennsylvania and California in September.

The inclusion of many of the most populous states makes Amazon’s shift all the more risky. Will shoppers continue to flock to the online superstore after some of its price advantage over bricks and mortar retailers vanishes?

Amazon is playing the role of tax collector under duress. Faced with multi-billion dollar budget shortfalls, legislators in a number of states have been trying to come up with new ways to fill their coffers. Amazon, the largest online retailer, was an obvious target.

For years, it has avoided the role of tax collector because it has no offices or warehouses in most states. Only companies with a physical presence, or nexus, in a state are required to collect sales taxes from customers who live there. Instead, shoppers are supposed to report what they owe for online purchases on their annual state tax form. But few of them do.

For the past three years, Amazon has only collected sales tax in five states — Kansas, Kentucky, New York, North Dakota and Washington — where it has offices or another physical presence.

Starting last year, legislators in a number of states passed laws to compel Amazon to collect sales tax. Bricks and mortar retailers like Sears SHLD and Best Buy (BBY), which already tack an extra 8% or so onto all purchases, pushed for the change as a way to level the playing field.

Under siege, Amazon switched from its usual combative strategy with the states to one of compromise. Agreements with a number of states let the retailer delay becoming tax collector for a few months and, in some cases, several years.

The exception is Pennsylvania, which revised its sales tax rules without an agreement with Amazon. So far, the company has not publicly challenged them.

Jason Brewer, a spokesman for the Retail Industry Leaders Association, a trade group of traditional retailers, quibbled with the terms of the agreements, saying “we would rather Amazon collect taxes soon rather than later.” But he added that “we appreciate the efforts that the states have gone to make Amazon play by the same rules as everyone else.”

In most of the deals, Amazon promised to open warehouses and create jobs. Legislators were happy to accept the offer at a time when the economy is struggling.

Amazon said in a statement that “we’ve always said we’re interested in bringing jobs to states with business-friendly climates.” However, the company said that it would prefer federal legislation to create a standard sales tax across the country rather than the state-by-state system currently in place.

Analysts have raised concerns about Amazon losing some of its pricing advantage by charging sales tax. But it is one of many risks facing the company, they point out, including the souring of the economy. Amazon minimizes the risk by saying that business is thriving in areas where it already charges sales tax. Those areas, most of which are overseas, account for half the company’s revenue.

Amazon’s new facilities, although costly, will help accommodate its rapid growth. They also raise the likelihood that the company will expand an online grocery shopping service that it is testing in the Seattle area. Such a service would require warehouses be closer to customers for same-day delivery. The company declined to comment on its plans for its grocery business.

Amazon’s deal with Texas ended a bitter fight with the state over back taxes. The Texas comptroller had sent Amazon a bill in 2010 for $269 million in uncollected sales tax after officials realized the company had a warehouse near Dallas.

Amazon had argued that the warehouse was owned by a subsidiary and therefore did not qualify as a physical presence. In retaliation for the tax bill, Amazon closed the facility.

It is unclear whether Amazon paid Texas any of those back taxes as part of the agreement, the details of which were kept confidential. The company did say it would create 2,500 jobs in the state and spend $200 million on capital improvements.

The California agreement followed an equally messy fight that started after state legislators passed a sales tax law aimed directly at Amazon last year. In response to the law, the company spent millions of dollars on a ballot initiative drive to repeal the law, but it eventually changed course.

The ultimate deal gave Amazon a one-year reprieve, ending September 15, from collecting sales tax. In return, Amazon promised to spend $500 million in the state. Two new warehouses are planned.

Amazon’s schedule for collecting sales taxes in other states is as follows: New Jersey and Virginia in 2013; and Indiana, Nevada and Tennessee in 2014. South Carolina is further down the road at 2016.