Updated

The Supreme Court on Monday struck down a Maryland tax that effectively double-taxes residents for income earned in other states -- a decision that could cost Maryland and other states with similar policies hundreds of millions of dollars.

In a 5-4 ruling, the justices agreed with a lower court that the tax is unconstitutional because it discourages Maryland residents from earning money outside the state.

"Maryland's tax scheme is inherently discriminatory," the justices wrote in the majority opinion. They wrote that the policy effectively discourages "interstate commerce."

The ruling said: "If every State adopted Maryland's tax structure, interstate commerce would be taxed at a higher rate than intrastate commerce."

The ruling could have far-reaching consequences beyond just Maryland. It also could affect similar laws in other states, including New York, Indiana, Pennsylvania and Ohio.

At issue in this case is Maryland's treatment of money earned out of state.

Most states give residents a full credit for income taxes paid on money earned out of state. Yet Maryland, while allowing residents to deduct income taxes paid to other states from their state tax, did not apply that deduction to a local "piggy back" tax collected for counties and some city governments.

Maryland claimed it had authority to tax all the income its residents earn to pay for local services like public schools.

The challenge to the policy was brought by a Maryland businessman who earned money in multiple states, and complained about the double-tax.

In the near-term, the court decision could cost Maryland hundreds of millions of taxpayer dollars.

The Associated Press contributed to this report.