An Illinois law aimed at leveling competition between online and brick-and-mortar retailers while collecting more state sales taxes is unconstitutional, the state supreme court ruled Friday, upholding a Cook County judge's decision.

The opinion is another shot in the highly contentious nationwide battle over who should collect online sales tax and how.

Consumers who live in sales-tax states, such as Illinois, owe state sales tax on their Internet purchases, whether they pay it during virtual checkout or when they file their state income tax returns. But few pay unless tax is collected at checkout. That has the effect of making online purchases cheaper than those at bricks-and-mortar retailers.

In March 2011, Illinois passed the Main Street Fairness Act, informally dubbed the Amazon-tax law. It expanded the meaning of a merchant's physical presence to include that of affiliate companies.

To avoid having to collect sales tax upon virtual checkout, some large Internet retailers, including Amazon.com, cut ties with affiliates in Illinois, which one trade group said numbered about 9,000.

After the law passed, some prominent Illinois-based Internet businesses, such as CouponCabin.com and FatWallet.com, fled to Indiana and Wisconsin rather than be cut off from commissions from Amazon.com, Overstock.com and others.

(c) 2013 McClatchy News Service.