Montgomery County might have to pay back $72.5 million in taxes after Maryland's highest court ruled counties were double-taxing people who should have been exempt.

The Maryland Court of Appeals has ruled that the state comptroller's collection of taxes on both in-state and out-of-state income is unconstitutional.

The Maryland Comptroller's Office has been collecting income tax on businesses and residents that pay income tax both in Maryland and in other states, but a ruling in the Maryland Court of Appeals says that is unconstitutional.

If the ruling is upheld, it could cost Montgomery County $72.5 million, the largest amount facing any county in the state, according to an analysis filed with the court. Baltimore County is second with $13.7 million.

Maryland Attorney General Douglas F. Gansler is asking the court to reconsider its ruling, with the state already filing an appeal.

The Court of Appeals ruling would let residents amend their tax returns in 2009, 2010 and 2011 to apply for county credits during those years. Businesses that pay both in-state and out-of-state income taxes are eligible under state law to get a tax credit for their out-of-state taxes.

Montgomery County Assistant Chief Administrative Officer Joe Beach said businesses that are based in Maryland and do business elsewhere in the country, like S corporations and limited liability companies,

are the most affected.

Montgomery County spokesman Patrick Lacefield said there is uncertainty about the ruling, but counties from across Maryland are banding together to express concern about how it would affect them.

Lacefield said county officials are working with state legislators, the Comptroller's Office and other counties to determine how the refunds would be given out if the ruling stands.

"The question is whether it's prospective or retroactive," Lacefield said. "It it from now on? Or do we have to go back a couple of years?"

Andrew Schaufele, director of the Bureau of Revenue Estimates within the Comptroller's Office, said the effect on local taxes could range between $45 million and $50 million annually, according to court documents.

The decision stems from a 2006 case in which Howard County resident Brian Wynne and his wife, Karen, claimed the credit on their taxes, and the Comptroller's Office raised the amount of local income tax paid to the county.

The Wynnes owned stock in Maxim Healthcare Services of Columbia, which provides home health services and medical staffing nationwide.

The Wynnes appealed the change on their taxes, which was denied in Maryland Tax Court in 2009. In 2011, the Howard County Circuit Court reversed the Tax Court's decision and the state appealed.