WASHINGTON—The IRS is preparing for an extended fight over a deduction created in the 2017 tax law that could put the government at odds with some of the largest U.S.-based multinational companies.

The Internal Revenue Service is auditing the first batches of tax returns that include the deduction for foreign-derived intangible income (FDII), and the government earlier this month unveiled a legal argument that shows it is likely to contest many companies’ claims.

In a memo to agency lawyers, Peter Blessing, the top international tax attorney at the IRS, outlined how the government intends to calculate the deduction for companies that fit two criteria: They have U.S. profit they earned from foreign sales and deductions for payments under deferred share-based compensation plans, such as restricted stock units granted in earlier years that vested after 2017.

In the memo, Mr. Blessing said the IRS was reversing a position it had taken on an analogous issue in 2009. That shift means companies that had calculated the deduction based on past IRS practice may find themselves facing unexpected tax bills.

“It’s a significant step and not one that they would take lightly,” said Michael Mollerus, a partner at law firm Davis, Polk & Wardwell LLP in New York who represents large companies.

The IRS memo was posted publicly but doesn’t disclose which companies are involved in any potential disputes. M any U.S.-based companies, however, claim FDII and report deductions for stock-compensation plans, including aircraft manufacturer Boeing Co. , sneaker giant Nike Inc., manufacturer 3M Co., and technology companies Microsoft Corp. and Texas Instruments Inc., according to securities filings. None of those companies have commented about the recent reversal in the IRS’s position.

Congress created FDII in the 2017 tax law, part of a restructuring of international tax rules. The idea was to give companies an incentive to locate intellectual property in the U.S. and serve foreign markets from the U.S. instead of abroad. Effectively, FDII creates a system where companies pay a 13.125% tax rate on domestic income from foreign sales, instead of the 21% tax rate they pay on purely domestic income and minimum tax rates in the low teens on foreign income.

The shift in the agency’s position has caught the attention of tax lawyers who typically represent multinational companies. They said they are taking the memo as a sign that the IRS is preparing to take this revised position into audits and in litigation against multiple companies.

“It seems like the IRS is trying to bolster a litigating position or warn taxpayers that they’re in for a fight,” said Layla Asali, an international tax attorney at Miller & Chevalier.

To some extent, the tax break has worked as intended, as companies including Microsoft and technology conglomerates Alphabet Inc. and Meta Platforms Inc. restructured their operations to book a greater share of global income in the U.S. than they did before 2017. FDII is projected to cost the government $26.3 billion in revenue this fiscal year, according to the congressional Joint Committee on Taxation.

FDII has to be calculated by figuring out how much income comes from foreign sales, and that’s where the disputes are starting.

Companies first claimed the tax break on their 2018 tax returns, which were typically filed in late 2019. Those filings are largely in the audit phase and it could be years before those audits lead to internal appeals, U.S. Tax Court cases and then any sort of binding precedent.

The technical legal question turns on how deductions for share-based compensation are considered when calculating FDII. Generally, for employee compensation such as restricted stock units, companies deduct the costs from their taxable income when the underlying equity vests, or becomes fully the employee’s to keep or sell, even if it was earned over several years before the 2017 tax law took effect.

According to the IRS, companies are arguing that those compensation deductions should not be fully counted against their income from post-2017 years when calculating FDII, because it was actually related to earlier years. That way, their compensation deductions for years with FDII appear smaller, their income from foreign sales is bigger and so is the FDII deduction they get for that.

The IRS agreed with that approach in 2009 on a similar domestic manufacturing deduction that has since been repealed. Now, it is taking the opposite view.

“Nothing really has changed since 2009,” said Gary Scanlon, a principal at accounting firm KPMG LLP’s Washington national tax group. “It is a bit surprising that they’ve reversed course, but it’s not surprising that they would re-examine the issue.”

In Mr. Blessing’s memo, the government says the compensation deductions should all be allocated to the current year’s income, to better align income and deductions. The result would shrink a company’s income from foreign sales, shrink its FDII deduction and increase its tax bill. The IRS declined to comment beyond its memo.

Over time, as companies are deducting less compensation earned before 2018, the particular dispute will fade.

For now, the memo is just a statement of the IRS’s position. Companies aren’t required to follow it because it is not a regulation or other binding rule, said Colleen O’Neill, a partner at accounting firm EY LLP. Companies will probably use the old guidance, Ms. O’Neill said.

Write to Richard Rubin at richard.rubin@wsj.com