In filing a lawsuit in Superior Court last week against online travel agencies, the District has joined one of the most contentious battles to engulf the hotel industry in years.

Jurisdictions across the country are turning to the courts to recoup millions in tax dollars they say companies such as Expedia, Priceline and Orbitz have been shorting them. There are about 40 pending lawsuits alleging that these online booking services pay taxes to cities based on wholesale room rates, not the higher retail prices that customers pay.

Online travel companies contend that the revenue comes from a service fee that is not taxable by municipalities. What’s more, they say, the lawsuits open a Pandora’s box of potential tax problems for their counterparts at brick-and-mortar agencies, who follow similar practices.

Wholesale rates are roughly 15 percent below the retail prices charged online, according to the District’s complaint. So the $200 room a traveler books on Expedia, for instance, really cost the company $170. From that lower rate, the District receives its 14.5 percent occupancy tax, while Expedia pockets the difference as a service fee.

Acting D.C. Attorney General Irvin Nathan estimates the city is losing between $4 million and $10 million a year. He is asking the court to compel the agencies to produce all accounting needed to determine the exact amount of unpaid sales taxes dating back to 1998.

Recovering those taxes would be a windfall not only for the District, which is facing a $400 million budget shortfall, but also for the tourism group Destination DC, which is funded by a percentage of the city’s hotel occupancy tax.

“You can’t create a new tax because of a bad economic climate,” said Andrew Weinstein, a spokesman for the Interactive Travel Services Association, the trade group that represents online travel companies. “The courts have looked at whether existing taxes apply to online companies, and the overwhelming majority rule that they do not.”

Cities across the country have indeed encountered mixed results in cases decided by the courts. Houston, for instance, lost its battle last March to collect hotel tax revenue from online agencies, while San Antonio won a judgment of $20.6 million against the agencies the previous winter.

Nathan said the language of the statutes governing hotel taxes is often the deciding factor in such cases. Taxing hotel operators, not hotel vendors, helps the case of online agents. But “the District of Columbia talks about the vendors who provide hotel rooms, and that leaves no question,” Nathan said.

The District’s lawsuit follows legislation passed in December by the D.C. Council to henceforth collect hotel taxes based on retail rates. Solomon Keene Jr., president of the Hotel Association of Washington, D.C., said he has been working with the Office of Tax and Revenue to ensure that the legislation is enforced.

Hotel operators have long had an uneasy relationship with online travel companies. In the wake of the recession, many upped their use of online agents, forking over an average 25 percent in commission, in a desperate need to fill rooms. Now that business is rebounding, some operators are debating the value of maintaining those relationships.