Behold: How Amazon wins the sales tax wars even when it loses

FORTUNE - Amazon CoverTaxes aren’t a sexy story. And the story of Amazon’s(s AMZN) long war against collecting sales tax tends to be reported in dribs and drabs, with coverage generally focusing on battles in individual states, which can make it even more boring to keep up with the issue (or maybe that’s just me). Peter Elkind’s cover story in this week’s issue of Fortune magazine, however, focuses on the entire saga.

Maneuvering to get around taxes isn’t unique to Amazon — note Apple’s own practice of keeping billions of dollars of profits offshore. The Fortune story makes it clear, though, that Amazon’s greatest advantage in the fight over collecting sales taxes has been its ability to adapt quickly to changes in the law — even if it’s simultaneously fighting those changes aggressively. When things don’t go its way, Elkind notes, “Amazon has shrewdly and successfully maneuvered to turn each development, good or bad, to its own advantage.” Part of this strategy simply means “going to extreme lengths — demanding, wheedling, suing, threatening, and negotiating — to avoid collecting for as long as possible, in as many states as possible.”

When Amazon is forced into collecting sales tax, though, it has been able to turn that into an advantage by “maneuvering to combine its needs (more warehouses) with its wants (preserving tax-free shopping for as long as possible).”

For instance, forced into collecting sales tax in South Carolina in 2010, Amazon “offered a compromise: It would start capturing sales tax in January 2016—almost five years later.” The South Carolina House rejected the compromise, and Amazon said it would leave the state and its “half-built warehouse.” Paul Misener, Amazon’s VP of global public policy, stated at a press conference, “The 1,200 jobs and nearly $100 million in capital investment that were coming to the state — aren’t.”

The House changed its mind three weeks later and Amazon will not collect sales tax in South Carolina until 2016. More recently, the retailer enacted a similar strategy in Texas, but there it was also able to secure a write-off of its own state tax bill. In addition, it will benefit from a “rebate” on the sales taxes collected in the suburbs where its warehouses are located. “This bonanza,” Elkind notes, “would run well into the millions.”

By 2016, Amazon (s AMZN) will actually be collecting taxes from 17 states, representing about half the U.S. population, and it’s agreed to collect sales taxes in every state where it has a warehouse. And the Marketplace Fairness Act, which would force large online merchants to collect sales tax on behalf of other states, recently passed the Senate. Amazon, which has long said it supports a federal solution for online taxes, supports the Marketplace Fairness Act.

Amazon also argues that its insistence on a federal solution is a matter of principle. Misener testified in Congress last year that “far from an e-commerce loophole, the constitutional limitation on states’ authority to collect sales tax is at the core of our nation’s founding principles.” He told Fortune, “We feel very good about our position because it’s a constitutional right.”

The full Fortune article is only available online to paying subscribers, meaning you may have to pick up a print copy. It’s well worth a read over the long weekend.